Added extension method to ServiceCollection to register default services
This commit is contained in:
parent
ce1f813a82
commit
4fc0b56dfa
|
|
@ -12,7 +12,7 @@ namespace MvcSample.Web
|
||||||
public void Configuration(IBuilder builder)
|
public void Configuration(IBuilder builder)
|
||||||
{
|
{
|
||||||
var services = new ServiceCollection();
|
var services = new ServiceCollection();
|
||||||
services.Add(MvcServices.GetDefaultServices());
|
services.AddMvc();
|
||||||
services.AddSingleton<PassThroughAttribute, PassThroughAttribute>();
|
services.AddSingleton<PassThroughAttribute, PassThroughAttribute>();
|
||||||
|
|
||||||
var serviceProvider = services.BuildServiceProvider(builder.ServiceProvider);
|
var serviceProvider = services.BuildServiceProvider(builder.ServiceProvider);
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
<Content Include="Project.json" />
|
<Content Include="Project.json" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="ServiceCollectionExtensions.cs" />
|
||||||
<Compile Include="MvcServices.cs" />
|
<Compile Include="MvcServices.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VSToolsPath)\ProjectK\Microsoft.Web.ProjectK.targets" Condition="'$(VSToolsPath)' != ''" />
|
<Import Project="$(VSToolsPath)\ProjectK\Microsoft.Web.ProjectK.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
using Microsoft.AspNet.DependencyInjection;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNet.Mvc
|
||||||
|
{
|
||||||
|
public static class ServiceCollectionExtensions
|
||||||
|
{
|
||||||
|
public static ServiceCollection AddMvc(this ServiceCollection services)
|
||||||
|
{
|
||||||
|
return services.Add(MvcServices.GetDefaultServices());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue