Skip to content

Commit

Permalink
Merge branch 'feature/samples' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
James Stumme authored and James Stumme committed Apr 3, 2017
2 parents d3986f9 + be1eadb commit 28d738a
Show file tree
Hide file tree
Showing 22 changed files with 422 additions and 14 deletions.
20 changes: 19 additions & 1 deletion RService.IO.sln
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{8183F92D
build\version.props = build\version.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{9BBD4CCC-ECA9-49A3-BDC6-EBECAE6C562A}"
ProjectSection(SolutionItems) = preProject
samples\README.md = samples\README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApiSample", "samples\WebApiSample\WebApiSample.csproj", "{0630EC05-F984-4683-A974-F3B67F20EF51}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RServiceSample", "samples\RServiceSample\RServiceSample.csproj", "{69CE6A1F-1815-4D5F-8844-F401A318C9B5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -64,6 +73,14 @@ Global
{44B66719-E3DC-4F39-A67D-196BCB9A0FA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{44B66719-E3DC-4F39-A67D-196BCB9A0FA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{44B66719-E3DC-4F39-A67D-196BCB9A0FA7}.Release|Any CPU.Build.0 = Release|Any CPU
{0630EC05-F984-4683-A974-F3B67F20EF51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0630EC05-F984-4683-A974-F3B67F20EF51}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0630EC05-F984-4683-A974-F3B67F20EF51}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0630EC05-F984-4683-A974-F3B67F20EF51}.Release|Any CPU.Build.0 = Release|Any CPU
{69CE6A1F-1815-4D5F-8844-F401A318C9B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{69CE6A1F-1815-4D5F-8844-F401A318C9B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{69CE6A1F-1815-4D5F-8844-F401A318C9B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{69CE6A1F-1815-4D5F-8844-F401A318C9B5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -75,6 +92,7 @@ Global
{4474DEEE-06F5-4706-97A2-A437E258F485} = {B748CB97-7861-4FC7-828D-11C44E540630}
{4FA0A7F5-B8AC-4BE0-BD20-7E2CDB16AE8B} = {B748CB97-7861-4FC7-828D-11C44E540630}
{44B66719-E3DC-4F39-A67D-196BCB9A0FA7} = {1F1CF499-A7DD-4BEE-B9B5-E5A87E0ADDA4}
{8183F92D-35F0-4362-896B-9BEEFE2EC1D0} = {64F366F9-AA78-455D-B3C7-94B9F14814AA}
{0630EC05-F984-4683-A974-F3B67F20EF51} = {9BBD4CCC-ECA9-49A3-BDC6-EBECAE6C562A}
{69CE6A1F-1815-4D5F-8844-F401A318C9B5} = {9BBD4CCC-ECA9-49A3-BDC6-EBECAE6C562A}
EndGlobalSection
EndGlobal
19 changes: 19 additions & 0 deletions samples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## RServiceSample
#### Preformance
*GET: /api/Values*
Cold call: 115.6812ms
Warm call: 0.6842ms

*GET: /api/Values/1*
Cold call: 61.1215ms
Warm call: 1.7148ms

## WebApiSample
####Preformance
*GET: /api/Values*
Cold call: 798.3171ms
Warm call: 3.9725ms

*GET: /api/Values/1*
Cold call: 76.3677ms
Warm call: 7.9050ms
10 changes: 10 additions & 0 deletions samples/RServiceSample/Models/AddItemValueReq.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using RService.IO.Abstractions;

namespace RServiceSample.Models
{
[Route("api/Values", RestVerbs.Post)]
public class AddItemValueReq
{
public string Value { get; set; }
}
}
10 changes: 10 additions & 0 deletions samples/RServiceSample/Models/GetItemValueReq.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using RService.IO.Abstractions;

namespace RServiceSample.Models
{
[Route("api/Values/{id}", RestVerbs.Get)]
public class GetItemValueReq
{
public int Id { get; set; }
}
}
10 changes: 10 additions & 0 deletions samples/RServiceSample/Models/RemoveItemValueReq.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using RService.IO.Abstractions;

namespace RServiceSample.Models
{
[Route("api/Values/{id}", RestVerbs.Delete)]
public class RemoveItemValueReq
{
public int Id { get; set; }
}
}
11 changes: 11 additions & 0 deletions samples/RServiceSample/Models/UpdateItemValueReq.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using RService.IO.Abstractions;

namespace RServiceSample.Models
{
[Route("api/Values/{id}", RestVerbs.Put)]
public class UpdateItemValueReq
{
public int Id { get; set; }
public string Value { get; set; }
}
}
21 changes: 21 additions & 0 deletions samples/RServiceSample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.IO;
using Microsoft.AspNetCore.Hosting;

namespace RServiceSample
{
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.UseApplicationInsights()
.Build();

host.Run();
}
}
}
27 changes: 27 additions & 0 deletions samples/RServiceSample/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:29697/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"RServiceSample": {
"commandName": "Project",
"launchUrl": "http://localhost:29698/api/Values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:29698"
}
}
}
18 changes: 18 additions & 0 deletions samples/RServiceSample/RServiceSample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\RService.IO\RService.IO.csproj" />
</ItemGroup>

</Project>
32 changes: 32 additions & 0 deletions samples/RServiceSample/Services/ValuesService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using RService.IO.Abstractions;
using System.Collections.Generic;
using RServiceSample.Models;

namespace RServiceSample.Services
{
public class ValuesService : ServiceBase
{
[Route("api/Values", RestVerbs.Get)]
public IEnumerable<string> Get()
{
return new[] {"value1", "value2"};
}

public string Get(GetItemValueReq req)
{
return "value";
}

public void Post(AddItemValueReq req)
{
}

public void Put(UpdateItemValueReq req)
{
}

public void Delete(RemoveItemValueReq req)
{
}
}
}
36 changes: 36 additions & 0 deletions samples/RServiceSample/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using RService.IO;
using RService.IO.DependencyIngection;
using RServiceSample.Services;

namespace RServiceSample
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddRServiceIo(options =>
{
options.AddServiceAssembly(typeof(ValuesService));
});
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();

if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseRServiceIo();
}
}
}
41 changes: 41 additions & 0 deletions samples/WebApiSample/Controllers/ValuesController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;

namespace WebApiSample.Controllers
{
[Route("api/[controller]")]
public class ValuesController : Controller
{
// GET api/values
[HttpGet]
public IEnumerable<string> Get()
{
return new[] { "value1", "value2" };
}

// GET api/values/5
[HttpGet("{id}")]
public string Get(int id)
{
return "value";
}

// POST api/values
[HttpPost]
public void Post([FromBody]string value)
{
}

// PUT api/values/5
[HttpPut("{id}")]
public void Put(int id, [FromBody]string value)
{
}

// DELETE api/values/5
[HttpDelete("{id}")]
public void Delete(int id)
{
}
}
}
21 changes: 21 additions & 0 deletions samples/WebApiSample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.IO;
using Microsoft.AspNetCore.Hosting;

namespace WebApiSample
{
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.UseApplicationInsights()
.Build();

host.Run();
}
}
}
29 changes: 29 additions & 0 deletions samples/WebApiSample/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:29642/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WebApiSample": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:29643"
}
}
}
39 changes: 39 additions & 0 deletions samples/WebApiSample/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

namespace WebApiSample
{
public class Startup
{
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", false, true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", true)
.AddEnvironmentVariables();
Configuration = builder.Build();
}

public IConfigurationRoot Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework 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, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();

app.UseMvc();
}
}
}
Loading

0 comments on commit 28d738a

Please sign in to comment.