Temporarily migrate the MvcSample project to Autofac

This commit is contained in:
Stephen Halter 2014-03-12 15:17:41 -07:00
parent 00f15669dc
commit cca3f92c5f
3 changed files with 15 additions and 4 deletions

View File

@ -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<PassThroughAttribute>(new PassThroughAttribute());
AutofacRegistration.Populate(containerBuilder, _serviceProvider, services);
containerBuilder.RegisterInstance<PassThroughAttribute>(new PassThroughAttribute());
var serviceProvider = containerBuilder.Build().Resolve<IServiceProvider>();
var routes = new RouteCollection()
{

View File

@ -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",

View File

@ -11,6 +11,11 @@ namespace Microsoft.AspNet.Mvc
{
public class MvcServices
{
public static IEnumerable<IServiceDescriptor> GetDefaultServices()
{
return GetDefaultServices(new Configuration());
}
public static IEnumerable<IServiceDescriptor> GetDefaultServices(IConfiguration configuration)
{
var describe = new ServiceDescriber(configuration);