Temporarily migrate the MvcSample project to Autofac
This commit is contained in:
parent
00f15669dc
commit
cca3f92c5f
|
|
@ -1,8 +1,10 @@
|
||||||
#if NET45
|
#if NET45
|
||||||
|
using Autofac;
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNet.Abstractions;
|
using Microsoft.AspNet.Abstractions;
|
||||||
using Microsoft.AspNet.ConfigurationModel;
|
using Microsoft.AspNet.ConfigurationModel;
|
||||||
using Microsoft.AspNet.DependencyInjection;
|
using Microsoft.AspNet.DependencyInjection;
|
||||||
|
using Microsoft.AspNet.DependencyInjection.Autofac;
|
||||||
using Microsoft.AspNet.Mvc;
|
using Microsoft.AspNet.Mvc;
|
||||||
using Microsoft.AspNet.Routing;
|
using Microsoft.AspNet.Routing;
|
||||||
using Microsoft.Net.Runtime;
|
using Microsoft.Net.Runtime;
|
||||||
|
|
@ -29,11 +31,13 @@ namespace MvcSample
|
||||||
|
|
||||||
private void ConfigureMvc(IBuilder builder)
|
private void ConfigureMvc(IBuilder builder)
|
||||||
{
|
{
|
||||||
var configuration = new Configuration();
|
var containerBuilder = new ContainerBuilder();
|
||||||
var services = MvcServices.GetDefaultServices(configuration);
|
var services = MvcServices.GetDefaultServices();
|
||||||
var serviceProvider = new ServiceProvider(_serviceProvider).Add(services);
|
|
||||||
|
|
||||||
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()
|
var routes = new RouteCollection()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,9 @@
|
||||||
"configurations": {
|
"configurations": {
|
||||||
"net45": {
|
"net45": {
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"Autofac": "3.3.0",
|
||||||
"Owin": "1.0",
|
"Owin": "1.0",
|
||||||
|
"Microsoft.AspNet.DependencyInjection.Autofac": "0.1-alpha-*",
|
||||||
"Microsoft.Owin": "2.1.0",
|
"Microsoft.Owin": "2.1.0",
|
||||||
"Microsoft.Owin.Diagnostics": "2.1.0",
|
"Microsoft.Owin.Diagnostics": "2.1.0",
|
||||||
"Microsoft.Owin.Hosting": "2.1.0",
|
"Microsoft.Owin.Hosting": "2.1.0",
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,11 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
public class MvcServices
|
public class MvcServices
|
||||||
{
|
{
|
||||||
|
public static IEnumerable<IServiceDescriptor> GetDefaultServices()
|
||||||
|
{
|
||||||
|
return GetDefaultServices(new Configuration());
|
||||||
|
}
|
||||||
|
|
||||||
public static IEnumerable<IServiceDescriptor> GetDefaultServices(IConfiguration configuration)
|
public static IEnumerable<IServiceDescriptor> GetDefaultServices(IConfiguration configuration)
|
||||||
{
|
{
|
||||||
var describe = new ServiceDescriber(configuration);
|
var describe = new ServiceDescriber(configuration);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue