Skip to content

Commit 863de8b

Browse files
committed
Added back a fully working sample
1 parent 74e0566 commit 863de8b

8 files changed

Lines changed: 174 additions & 1 deletion

File tree

StructureMap.Microsoft.DependencyInjection.sln

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
44
VisualStudioVersion = 15.0.26430.14
@@ -26,6 +26,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StructureMap.Microsoft.Depe
2626
EndProject
2727
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StructureMap.AspNetCore", "src\StructureMap.AspNetCore\StructureMap.AspNetCore.csproj", "{6B38D654-FE83-4594-B99B-E73F117DDCE6}"
2828
EndProject
29+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureMap.AspNetCore.Sample", "sample\StructureMap.AspNetCore.Sample\StructureMap.AspNetCore.Sample.csproj", "{7A42E6D6-0199-41EC-8612-B1700961135C}"
30+
EndProject
2931
Global
3032
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3133
Debug|Any CPU = Debug|Any CPU
@@ -44,6 +46,10 @@ Global
4446
{6B38D654-FE83-4594-B99B-E73F117DDCE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
4547
{6B38D654-FE83-4594-B99B-E73F117DDCE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
4648
{6B38D654-FE83-4594-B99B-E73F117DDCE6}.Release|Any CPU.Build.0 = Release|Any CPU
49+
{7A42E6D6-0199-41EC-8612-B1700961135C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
50+
{7A42E6D6-0199-41EC-8612-B1700961135C}.Debug|Any CPU.Build.0 = Debug|Any CPU
51+
{7A42E6D6-0199-41EC-8612-B1700961135C}.Release|Any CPU.ActiveCfg = Release|Any CPU
52+
{7A42E6D6-0199-41EC-8612-B1700961135C}.Release|Any CPU.Build.0 = Release|Any CPU
4753
EndGlobalSection
4854
GlobalSection(SolutionProperties) = preSolution
4955
HideSolutionNode = FALSE
@@ -52,6 +58,7 @@ Global
5258
{D09D9E47-E9B7-4446-90AE-48AE3358C880} = {1AAD948C-6BBE-4334-BFF2-AA5F16F63845}
5359
{2B3D64C5-CA4D-41E5-AF3A-BA90AB80EB60} = {8037CE7A-020C-48D2-9C7E-BBEB669E19D7}
5460
{6B38D654-FE83-4594-B99B-E73F117DDCE6} = {1AAD948C-6BBE-4334-BFF2-AA5F16F63845}
61+
{7A42E6D6-0199-41EC-8612-B1700961135C} = {5C06EB0A-91A1-4FA1-801C-ABEDAEDBF87B}
5562
EndGlobalSection
5663
GlobalSection(ExtensibilityGlobals) = postSolution
5764
SolutionGuid = {B31A59D6-59DC-47FD-9B37-D6F28BEBB184}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc;
6+
7+
namespace StructureMap.AspNetCore.Sample.Controllers
8+
{
9+
[Route("api/[controller]")]
10+
[ApiController]
11+
public class ValuesController : ControllerBase
12+
{
13+
// GET api/values
14+
[HttpGet]
15+
public ActionResult<IEnumerable<string>> Get()
16+
{
17+
return new string[] { "value1", "value2" };
18+
}
19+
20+
// GET api/values/5
21+
[HttpGet("{id}")]
22+
public ActionResult<string> Get(int id)
23+
{
24+
return "value";
25+
}
26+
27+
// POST api/values
28+
[HttpPost]
29+
public void Post([FromBody] string value)
30+
{
31+
}
32+
33+
// PUT api/values/5
34+
[HttpPut("{id}")]
35+
public void Put(int id, [FromBody] string value)
36+
{
37+
}
38+
39+
// DELETE api/values/5
40+
[HttpDelete("{id}")]
41+
public void Delete(int id)
42+
{
43+
}
44+
}
45+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Microsoft.AspNetCore;
2+
using Microsoft.AspNetCore.Hosting;
3+
4+
namespace StructureMap.AspNetCore.Sample
5+
{
6+
public static class Program
7+
{
8+
public static void Main(string[] args)
9+
{
10+
CreateWebHostBuilder(args).Build().Run();
11+
}
12+
13+
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
14+
WebHost.CreateDefaultBuilder(args)
15+
.UseStructureMap() // Add support for StructureMap
16+
.UseStartup<Startup>();
17+
}
18+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"$schema": "http://json.schemastore.org/launchsettings.json",
3+
"iisSettings": {
4+
"windowsAuthentication": false,
5+
"anonymousAuthentication": true,
6+
"iisExpress": {
7+
"applicationUrl": "http://localhost:56358",
8+
"sslPort": 0
9+
}
10+
},
11+
"profiles": {
12+
"IIS Express": {
13+
"commandName": "IISExpress",
14+
"launchBrowser": true,
15+
"launchUrl": "api/values",
16+
"environmentVariables": {
17+
"ASPNETCORE_ENVIRONMENT": "Development"
18+
}
19+
},
20+
"StructureMap.AspNetCore.Sample": {
21+
"commandName": "Project",
22+
"launchBrowser": true,
23+
"launchUrl": "api/values",
24+
"applicationUrl": "http://localhost:5000",
25+
"environmentVariables": {
26+
"ASPNETCORE_ENVIRONMENT": "Development"
27+
}
28+
}
29+
}
30+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using Microsoft.AspNetCore.Builder;
2+
using Microsoft.AspNetCore.Hosting;
3+
using Microsoft.AspNetCore.Mvc;
4+
using Microsoft.Extensions.Configuration;
5+
using Microsoft.Extensions.DependencyInjection;
6+
7+
namespace StructureMap.AspNetCore.Sample
8+
{
9+
public class Startup
10+
{
11+
public Startup(IConfiguration configuration)
12+
{
13+
Configuration = configuration;
14+
}
15+
16+
public IConfiguration Configuration { get; }
17+
18+
// This method gets called by the runtime. Use this method to add services to the container.
19+
public void ConfigureServices(IServiceCollection services)
20+
{
21+
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
22+
}
23+
24+
// This method gets called by the runtime. Use this method to add services, using StructureMap-specific APIs.
25+
public void ConfigureContainer(Registry registry)
26+
{
27+
}
28+
29+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
30+
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
31+
{
32+
if (env.IsDevelopment())
33+
{
34+
app.UseDeveloperExceptionPage();
35+
}
36+
37+
app.UseMvc();
38+
}
39+
}
40+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
<PropertyGroup>
3+
<TargetFramework>netcoreapp2.2</TargetFramework>
4+
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Microsoft.AspNetCore.App" />
9+
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
10+
<PackageReference Include="StructureMap" Version="4.5.0" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<ProjectReference Include="..\..\src\StructureMap.AspNetCore\StructureMap.AspNetCore.csproj" />
15+
</ItemGroup>
16+
</Project>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Debug",
5+
"System": "Information",
6+
"Microsoft": "Information"
7+
}
8+
}
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Warning"
5+
}
6+
},
7+
"AllowedHosts": "*"
8+
}

0 commit comments

Comments
 (0)