From 4fc0b56dfa785345cb37d66e15e2c89e055cee87 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Tue, 15 Apr 2014 21:18:37 -0700 Subject: [PATCH] Added extension method to ServiceCollection to register default services --- samples/MvcSample.Web/Startup.cs | 2 +- src/Microsoft.AspNet.Mvc/Microsoft.AspNet.Mvc.kproj | 1 + .../ServiceCollectionExtensions.cs | 13 +++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/Microsoft.AspNet.Mvc/ServiceCollectionExtensions.cs diff --git a/samples/MvcSample.Web/Startup.cs b/samples/MvcSample.Web/Startup.cs index 04413a785b..fbf385796f 100644 --- a/samples/MvcSample.Web/Startup.cs +++ b/samples/MvcSample.Web/Startup.cs @@ -12,7 +12,7 @@ namespace MvcSample.Web public void Configuration(IBuilder builder) { var services = new ServiceCollection(); - services.Add(MvcServices.GetDefaultServices()); + services.AddMvc(); services.AddSingleton(); var serviceProvider = services.BuildServiceProvider(builder.ServiceProvider); diff --git a/src/Microsoft.AspNet.Mvc/Microsoft.AspNet.Mvc.kproj b/src/Microsoft.AspNet.Mvc/Microsoft.AspNet.Mvc.kproj index c1b586a170..73f8a18ab1 100644 --- a/src/Microsoft.AspNet.Mvc/Microsoft.AspNet.Mvc.kproj +++ b/src/Microsoft.AspNet.Mvc/Microsoft.AspNet.Mvc.kproj @@ -20,6 +20,7 @@ + diff --git a/src/Microsoft.AspNet.Mvc/ServiceCollectionExtensions.cs b/src/Microsoft.AspNet.Mvc/ServiceCollectionExtensions.cs new file mode 100644 index 0000000000..6f91d32efe --- /dev/null +++ b/src/Microsoft.AspNet.Mvc/ServiceCollectionExtensions.cs @@ -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()); + } + } +}