diff --git a/samples/MvcSample/Startup.cs b/samples/MvcSample/Startup.cs index 780d0e89ed..9e512a9c39 100644 --- a/samples/MvcSample/Startup.cs +++ b/samples/MvcSample/Startup.cs @@ -1,8 +1,10 @@ #if NET45 +using Autofac; using System; using Microsoft.AspNet.Abstractions; using Microsoft.AspNet.ConfigurationModel; using Microsoft.AspNet.DependencyInjection; +using Microsoft.AspNet.DependencyInjection.Autofac; using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Routing; using Microsoft.Net.Runtime; @@ -29,11 +31,13 @@ namespace MvcSample private void ConfigureMvc(IBuilder builder) { - var configuration = new Configuration(); - var services = MvcServices.GetDefaultServices(configuration); - var serviceProvider = new ServiceProvider(_serviceProvider).Add(services); + var containerBuilder = new ContainerBuilder(); + var services = MvcServices.GetDefaultServices(); - serviceProvider.AddInstance(new PassThroughAttribute()); + AutofacRegistration.Populate(containerBuilder, _serviceProvider, services); + containerBuilder.RegisterInstance(new PassThroughAttribute()); + + var serviceProvider = containerBuilder.Build().Resolve(); var routes = new RouteCollection() { diff --git a/samples/MvcSample/project.json b/samples/MvcSample/project.json index c4ef088f35..e695307774 100644 --- a/samples/MvcSample/project.json +++ b/samples/MvcSample/project.json @@ -14,7 +14,9 @@ "configurations": { "net45": { "dependencies": { + "Autofac": "3.3.0", "Owin": "1.0", + "Microsoft.AspNet.DependencyInjection.Autofac": "0.1-alpha-*", "Microsoft.Owin": "2.1.0", "Microsoft.Owin.Diagnostics": "2.1.0", "Microsoft.Owin.Hosting": "2.1.0", diff --git a/src/Microsoft.AspNet.Mvc/MvcServices.cs b/src/Microsoft.AspNet.Mvc/MvcServices.cs index 26bb98a685..ef2d423c2a 100644 --- a/src/Microsoft.AspNet.Mvc/MvcServices.cs +++ b/src/Microsoft.AspNet.Mvc/MvcServices.cs @@ -11,6 +11,11 @@ namespace Microsoft.AspNet.Mvc { public class MvcServices { + public static IEnumerable GetDefaultServices() + { + return GetDefaultServices(new Configuration()); + } + public static IEnumerable GetDefaultServices(IConfiguration configuration) { var describe = new ServiceDescriber(configuration);