Skip to content

Moved to netstandard 2.0 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -215,3 +215,5 @@ pip-log.txt

#Mr Developer
.mr.developer.cfg

.idea
19 changes: 6 additions & 13 deletions samples/WebApiConsole/Controllers/FooController.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using System.Net.Http;
using Microsoft.AspNetCore.Mvc;

namespace WebApiConsole.Controllers
{
public class FooController : ApiController
public class FooController : Controller
{

[EntryPointRelation("http://example.org/rels/foo")]
public HttpResponseMessage Get(int id)
{
@@ -21,12 +15,11 @@ public HttpResponseMessage Get(int id)
public HttpResponseMessage Post(int id)
{
return null;
}
}
}

public class BarController : ApiController
public class BarController : Controller
{

[EntryPointRelation("http://example.org/rels/bar")]
public HttpResponseMessage Get(HttpRequestMessage request)
{
@@ -38,4 +31,4 @@ public HttpResponseMessage Get(HttpRequestMessage request)
// return null;
//}
}
}
}
46 changes: 18 additions & 28 deletions samples/WebApiConsole/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Description;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Tavis;
using Tavis.Home;
using Tavis.IANA;

namespace WebApiConsole.Controllers
{
public class HomeController : ApiController
public class HomeController : Controller
{

public HttpResponseMessage Get(HttpRequestMessage requestMessage)
public async Task Index()
{
var homeDocument = new HomeDocument();


var fooLink = new Link()
{
Relation = "http://example.org/rels/foo",
Target = new Uri("foo", UriKind.Relative)
};
{
Relation = "http://example.org/rels/foo",
Target = new Uri("foo", UriKind.Relative)
};
var allowHint = new AllowHint();
allowHint.AddMethod(HttpMethod.Get);
allowHint.AddMethod(HttpMethod.Post);
@@ -51,28 +45,26 @@ public HttpResponseMessage Get(HttpRequestMessage requestMessage)
Relation = "http://example.org/rels/bar2",
Target = new Uri("bar/{id}", UriKind.Relative)
};
// bar2Link.SetParameter("id","",new Uri("template/params/id", UriKind.Relative));
// bar2Link.SetParameter("id","",new Uri("template/params/id", UriKind.Relative));
homeDocument.AddResource(bar2Link);


var ms = new MemoryStream();
homeDocument.Save(ms);
ms.Position = 0;
var streamContent = new StreamContent(ms);
return new HttpResponseMessage()
{
Content = streamContent
};


await ms.CopyToAsync(this.Response.Body);
}


//public HttpResponseMessage Get2(HttpRequestMessage requestMessage)
//{


// var homeDocument = new HomeDocument();


// IApiExplorer apiExplorer = Configuration.Services.GetApiExplorer();

// var resources = from ad in apiExplorer.ApiDescriptions
@@ -85,7 +77,7 @@ public HttpResponseMessage Get(HttpRequestMessage requestMessage)
// {
// var apiDescription = res.First();
// var atts = apiDescription.ActionDescriptor.GetCustomAttributes<EntryPointRelationAttribute>();

// // Get EntryPoint Link relation name
// var epr = atts.FirstOrDefault();
// if (epr != null)
@@ -125,16 +117,14 @@ public HttpResponseMessage Get(HttpRequestMessage requestMessage)
// var streamContent = new StreamContent(stream);
// streamContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
// var responseMessage = new HttpResponseMessage() {Content = streamContent};

// return responseMessage;

//}

private string MakeQueryString(ApiDescription ad)
{
return String.Empty;
}
}


}
}
6 changes: 1 addition & 5 deletions samples/WebApiConsole/EntryPointRelationAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WebApiConsole
{
@@ -20,4 +16,4 @@ public string Name
get { return _name; }
}
}
}
}
50 changes: 20 additions & 30 deletions samples/WebApiConsole/Program.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Web.Http;
using System.Web.Http.Description;
using System.Web.Http.SelfHost;
using Tavis;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;

namespace WebApiConsole
{
class Program
{
static void Main(string[] args)
static async Task Main(string[] args)
{


var baseAddress = "http://localhost:8080";
var config = new HttpSelfHostConfiguration(baseAddress);

config.Routes.MapHttpRoute("defaultWithId", "api/{controller}/{id}");
config.Routes.MapHttpRoute("default", "api/{controller}");
//config.Routes.MapHttpRoute("default", "api/{controller}/{id}", new {id= RouteParameter.Optional});


var server = new HttpSelfHostServer(config);


Console.WriteLine("Opening server at " + baseAddress);
server.OpenAsync().Wait();

Console.WriteLine("Press enter to shutdown server");
Console.ReadLine();
server.CloseAsync().Wait();
await WebHost.CreateDefaultBuilder<Startup>(args).Build().RunAsync();
}
}

public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseMvcWithDefaultRoute();
}
}
}
}
36 changes: 0 additions & 36 deletions samples/WebApiConsole/Properties/AssemblyInfo.cs

This file was deleted.

107 changes: 6 additions & 101 deletions samples/WebApiConsole/WebApiConsole.csproj
Original file line number Diff line number Diff line change
@@ -1,109 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{40BCCD0F-FAF7-4E11-8C7C-072020362FDF}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WebApiConsole</RootNamespace>
<AssemblyName>WebApiConsole</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\src\</SolutionDir>
<RestorePackages>true</RestorePackages>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Web.Http.SelfHost, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.SelfHost.5.2.3\lib\net45\System.Web.Http.SelfHost.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="Tavis.Link, Version=0.1.5938.41532, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Tavis.Link.2.5\lib\portable-net45+sl5+wp8+win8+wpa81+MonoTouch1+MonoAndroid1\Tavis.Link.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Tavis.UriTemplates, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\Tavis.UriTemplates.1.0.0\lib\Net45\Tavis.UriTemplates.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Controllers\FooController.cs" />
<Compile Include="Controllers\HomeController.cs" />
<Compile Include="EntryPointRelationAttribute.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Home\Home.csproj">
<Project>{151aef3f-322e-4968-9642-25857a4d2ed9}</Project>
<Name>Home</Name>
</ProjectReference>
<ProjectReference Include="../../src/Home/Home.csproj" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Loading