Added extension method to ServiceCollection to register default services

This commit is contained in:
David Fowler 2014-04-15 21:18:37 -07:00
parent ce1f813a82
commit 4fc0b56dfa
3 changed files with 15 additions and 1 deletions

View File

@ -12,7 +12,7 @@ namespace MvcSample.Web
public void Configuration(IBuilder builder)
{
var services = new ServiceCollection();
services.Add(MvcServices.GetDefaultServices());
services.AddMvc();
services.AddSingleton<PassThroughAttribute, PassThroughAttribute>();
var serviceProvider = services.BuildServiceProvider(builder.ServiceProvider);

View File

@ -20,6 +20,7 @@
<Content Include="Project.json" />
</ItemGroup>
<ItemGroup>
<Compile Include="ServiceCollectionExtensions.cs" />
<Compile Include="MvcServices.cs" />
</ItemGroup>
<Import Project="$(VSToolsPath)\ProjectK\Microsoft.Web.ProjectK.targets" Condition="'$(VSToolsPath)' != ''" />

View File

@ -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());
}
}
}