Switching to the official Autofac package.
This commit is contained in:
parent
0ef68eefc8
commit
43e4870fa2
|
|
@ -1,10 +1,10 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#if DNX451
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Autofac.Core;
|
||||
|
|
@ -108,4 +108,3 @@ namespace MvcSample.Web
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#if DNX451
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using Autofac;
|
||||
|
|
@ -77,4 +76,3 @@ namespace MvcSample.Web
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2,22 +2,15 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
#if DNX451
|
||||
using System.IO;
|
||||
using Autofac;
|
||||
#endif
|
||||
using Autofac.Framework.DependencyInjection;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Razor;
|
||||
#if DNX451
|
||||
using Microsoft.Framework.Configuration;
|
||||
#endif
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
#if DNX451
|
||||
using Microsoft.Framework.DependencyInjection.Autofac;
|
||||
using Microsoft.Dnx.Runtime;
|
||||
using Microsoft.Dnx.Runtime.Infrastructure;
|
||||
#endif
|
||||
using MvcSample.Web.Filters;
|
||||
using MvcSample.Web.Services;
|
||||
|
||||
|
|
@ -25,9 +18,7 @@ namespace MvcSample.Web
|
|||
{
|
||||
public class Startup
|
||||
{
|
||||
#if DNX451
|
||||
private bool _autoFac;
|
||||
#endif
|
||||
|
||||
public IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
|
|
@ -48,10 +39,6 @@ namespace MvcSample.Web
|
|||
|
||||
services.AddMvcLocalization(LanguageViewLocationExpanderFormat.SubFolder);
|
||||
|
||||
#if DNX451
|
||||
// Fully-qualify configuration path to avoid issues in functional tests. Just "config.json" would be fine
|
||||
// but Configuration uses CallContextServiceLocator.Locator.ServiceProvider to get IApplicationEnvironment.
|
||||
// Functional tests update that service but not in the static provider.
|
||||
var applicationEnvironment = services.BuildServiceProvider().GetRequiredService<IApplicationEnvironment>();
|
||||
var configurationPath = Path.Combine(applicationEnvironment.ApplicationBasePath, "config.json");
|
||||
|
||||
|
|
@ -72,9 +59,7 @@ namespace MvcSample.Web
|
|||
var builder = new ContainerBuilder();
|
||||
|
||||
// Create the container and use the default application services as a fallback
|
||||
AutofacRegistration.Populate(
|
||||
builder,
|
||||
services);
|
||||
builder.Populate(services);
|
||||
|
||||
builder.RegisterModule<MonitoringModule>();
|
||||
|
||||
|
|
@ -83,7 +68,6 @@ namespace MvcSample.Web
|
|||
return container.Resolve<IServiceProvider>();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
return services.BuildServiceProvider();
|
||||
}
|
||||
|
|
@ -94,12 +78,10 @@ namespace MvcSample.Web
|
|||
app.UseStatusCodePages();
|
||||
app.UseFileServer();
|
||||
|
||||
#if DNX451
|
||||
if (_autoFac)
|
||||
{
|
||||
app.UseMiddleware<MonitoringMiddlware>();
|
||||
}
|
||||
#endif
|
||||
app.UseRequestLocalization();
|
||||
|
||||
app.UseSession();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
"warningsAsErrors": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Autofac.Framework.DependencyInjection": "4.0.0-*",
|
||||
"Kestrel": "1.0.0-*",
|
||||
"Microsoft.AspNet.Diagnostics": "1.0.0-*",
|
||||
"Microsoft.AspNet.Localization": "1.0.0-*",
|
||||
|
|
@ -17,19 +18,19 @@
|
|||
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
|
||||
"Microsoft.AspNet.Session": "1.0.0-*",
|
||||
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
|
||||
"Microsoft.Framework.PropertyHelper.Sources": { "version": "1.0.0-*", "type": "build" },
|
||||
"Microsoft.Framework.NotNullAttribute.Sources": { "type": "build", "version": "1.0.0-*" }
|
||||
"Microsoft.Framework.Configuration.Json": "1.0.0-*",
|
||||
"Microsoft.Framework.PropertyHelper.Sources": {
|
||||
"version": "1.0.0-*",
|
||||
"type": "build"
|
||||
},
|
||||
"Microsoft.Framework.NotNullAttribute.Sources": {
|
||||
"type": "build",
|
||||
"version": "1.0.0-*"
|
||||
}
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": {
|
||||
"dependencies": {
|
||||
"Microsoft.Framework.DependencyInjection.Autofac": "1.0.0-*",
|
||||
"Microsoft.Framework.Configuration.Json": "1.0.0-*"
|
||||
}
|
||||
},
|
||||
"dnxcore50": {
|
||||
"dependencies": { }
|
||||
}
|
||||
"dnx451": { },
|
||||
"dnxcore50": { }
|
||||
},
|
||||
"exclude": [
|
||||
"wwwroot",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#if DNX451
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using AutofacWebSite;
|
||||
|
|
@ -34,4 +33,3 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,83 +1,83 @@
|
|||
{
|
||||
"compile": [
|
||||
"../Microsoft.AspNet.Mvc.Formatters.Xml.Test/XmlAssert.cs"
|
||||
],
|
||||
"compilationOptions": {
|
||||
"define": [ "__RemoveThisBitTo__GENERATE_BASELINES" ],
|
||||
"warningsAsErrors": "true"
|
||||
},
|
||||
"dependencies": {
|
||||
"ActionConstraintsWebSite": "1.0.0",
|
||||
"ActionResultsWebSite": "1.0.0",
|
||||
"ActivatorWebSite": "1.0.0",
|
||||
"AddServicesWebSite": "1.0.0",
|
||||
"AntiforgeryTokenWebSite": "1.0.0",
|
||||
"ApiExplorerWebSite": "1.0.0",
|
||||
"ApplicationModelWebSite": "1.0.0",
|
||||
"BasicWebSite": "1.0.0",
|
||||
"BestEffortLinkGenerationWebSite": "1.0.0",
|
||||
"CompositeViewEngineWebSite": "1.0.0",
|
||||
"ContentNegotiationWebSite": "1.0.0",
|
||||
"ControllerDiscoveryConventionsWebSite": "1.0.0",
|
||||
"ControllersFromServicesWebSite": "1.0.0",
|
||||
"CorsMiddlewareWebSite": "1.0.0",
|
||||
"CorsWebSite": "1.0.0",
|
||||
"CustomRouteWebSite": "1.0.0",
|
||||
"ErrorPageMiddlewareWebSite": "1.0.0",
|
||||
"FilesWebSite": "1.0.0",
|
||||
"FiltersWebSite": "1.0.0",
|
||||
"FormatFilterWebSite": "1.0.0-*",
|
||||
"FormatterWebSite": "1.0.0",
|
||||
"HtmlGenerationWebSite": "1.0.0",
|
||||
"InlineConstraintsWebSite": "1.0.0",
|
||||
"JsonPatchWebSite": "1.0.0",
|
||||
"LocalizationWebSite": "1.0.0",
|
||||
"LoggingWebSite": "1.0.0",
|
||||
"LowercaseUrlsWebSite": "1.0.0-*",
|
||||
"Microsoft.AspNet.Mvc": "6.0.0-*",
|
||||
"Microsoft.AspNet.Mvc.TestCommon": { "version": "6.0.0-*", "type": "build" },
|
||||
"Microsoft.AspNet.Mvc.TestConfiguration": "1.0.0",
|
||||
"Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
|
||||
"Microsoft.AspNet.TestHost": "1.0.0-*",
|
||||
"Microsoft.AspNet.WebUtilities": "1.0.0-*",
|
||||
"Microsoft.Framework.Configuration.Json": "1.0.0-*",
|
||||
"ModelBindingWebSite": "1.0.0",
|
||||
"MvcSample.Web": "1.0.0",
|
||||
"PrecompilationWebSite": "1.0.0",
|
||||
"RazorCompilerCacheWebSite": "1.0.0",
|
||||
"RazorEmbeddedViewsWebSite": "1.0.0",
|
||||
"RazorPageExecutionInstrumentationWebSite": "1.0.0",
|
||||
"RazorWebSite": "1.0.0",
|
||||
"RequestServicesWebSite": "1.0.0",
|
||||
"ResponseCacheWebSite": "1.0.0",
|
||||
"RoutingWebSite": "1.0.0",
|
||||
"TagHelperSample.Web": "1.0.0",
|
||||
"TagHelpersWebSite": "1.0.0",
|
||||
"TempDataWebSite": "1.0.0",
|
||||
"UrlHelperWebSite": "1.0.0",
|
||||
"ValidationWebSite": "1.0.0",
|
||||
"ValueProvidersWebSite": "1.0.0",
|
||||
"VersioningWebSite": "1.0.0",
|
||||
"ViewComponentWebSite": "1.0.0",
|
||||
"WebApiCompatShimWebSite": "1.0.0",
|
||||
"XmlFormattersWebSite": "1.0.0",
|
||||
"xunit.runner.aspnet": "2.0.0-aspnet-*"
|
||||
},
|
||||
"commands": {
|
||||
"test": "xunit.runner.aspnet"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": {
|
||||
"dependencies": {
|
||||
"AutofacWebSite": "1.0.0"
|
||||
}
|
||||
"compile": [
|
||||
"../Microsoft.AspNet.Mvc.Formatters.Xml.Test/XmlAssert.cs"
|
||||
],
|
||||
"compilationOptions": {
|
||||
"define": [ "__RemoveThisBitTo__GENERATE_BASELINES" ],
|
||||
"warningsAsErrors": "true"
|
||||
},
|
||||
"dnxcore50": {
|
||||
}
|
||||
},
|
||||
"exclude": [
|
||||
"wwwroot",
|
||||
"node_modules",
|
||||
"bower_components"
|
||||
]
|
||||
"dependencies": {
|
||||
"ActionConstraintsWebSite": "1.0.0",
|
||||
"ActionResultsWebSite": "1.0.0",
|
||||
"ActivatorWebSite": "1.0.0",
|
||||
"AddServicesWebSite": "1.0.0",
|
||||
"AntiforgeryTokenWebSite": "1.0.0",
|
||||
"ApiExplorerWebSite": "1.0.0",
|
||||
"ApplicationModelWebSite": "1.0.0",
|
||||
"AutofacWebSite": "1.0.0",
|
||||
"BasicWebSite": "1.0.0",
|
||||
"BestEffortLinkGenerationWebSite": "1.0.0",
|
||||
"CompositeViewEngineWebSite": "1.0.0",
|
||||
"ContentNegotiationWebSite": "1.0.0",
|
||||
"ControllerDiscoveryConventionsWebSite": "1.0.0",
|
||||
"ControllersFromServicesWebSite": "1.0.0",
|
||||
"CorsMiddlewareWebSite": "1.0.0",
|
||||
"CorsWebSite": "1.0.0",
|
||||
"CustomRouteWebSite": "1.0.0",
|
||||
"ErrorPageMiddlewareWebSite": "1.0.0",
|
||||
"FilesWebSite": "1.0.0",
|
||||
"FiltersWebSite": "1.0.0",
|
||||
"FormatFilterWebSite": "1.0.0-*",
|
||||
"FormatterWebSite": "1.0.0",
|
||||
"HtmlGenerationWebSite": "1.0.0",
|
||||
"InlineConstraintsWebSite": "1.0.0",
|
||||
"JsonPatchWebSite": "1.0.0",
|
||||
"LocalizationWebSite": "1.0.0",
|
||||
"LoggingWebSite": "1.0.0",
|
||||
"LowercaseUrlsWebSite": "1.0.0-*",
|
||||
"Microsoft.AspNet.Mvc": "6.0.0-*",
|
||||
"Microsoft.AspNet.Mvc.TestCommon": {
|
||||
"version": "6.0.0-*",
|
||||
"type": "build"
|
||||
},
|
||||
"Microsoft.AspNet.Mvc.TestConfiguration": "1.0.0",
|
||||
"Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
|
||||
"Microsoft.AspNet.TestHost": "1.0.0-*",
|
||||
"Microsoft.AspNet.WebUtilities": "1.0.0-*",
|
||||
"Microsoft.Framework.Configuration.Json": "1.0.0-*",
|
||||
"ModelBindingWebSite": "1.0.0",
|
||||
"MvcSample.Web": "1.0.0",
|
||||
"PrecompilationWebSite": "1.0.0",
|
||||
"RazorCompilerCacheWebSite": "1.0.0",
|
||||
"RazorEmbeddedViewsWebSite": "1.0.0",
|
||||
"RazorPageExecutionInstrumentationWebSite": "1.0.0",
|
||||
"RazorWebSite": "1.0.0",
|
||||
"RequestServicesWebSite": "1.0.0",
|
||||
"ResponseCacheWebSite": "1.0.0",
|
||||
"RoutingWebSite": "1.0.0",
|
||||
"TagHelperSample.Web": "1.0.0",
|
||||
"TagHelpersWebSite": "1.0.0",
|
||||
"TempDataWebSite": "1.0.0",
|
||||
"UrlHelperWebSite": "1.0.0",
|
||||
"ValidationWebSite": "1.0.0",
|
||||
"ValueProvidersWebSite": "1.0.0",
|
||||
"VersioningWebSite": "1.0.0",
|
||||
"ViewComponentWebSite": "1.0.0",
|
||||
"WebApiCompatShimWebSite": "1.0.0",
|
||||
"XmlFormattersWebSite": "1.0.0",
|
||||
"xunit.runner.aspnet": "2.0.0-aspnet-*"
|
||||
},
|
||||
"commands": {
|
||||
"test": "xunit.runner.aspnet"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": { },
|
||||
"dnxcore50": {
|
||||
}
|
||||
},
|
||||
"exclude": [
|
||||
"wwwroot",
|
||||
"node_modules",
|
||||
"bower_components"
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
using System;
|
||||
using Autofac;
|
||||
using Autofac.Framework.DependencyInjection;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.Framework.DependencyInjection;
|
||||
using Microsoft.Framework.DependencyInjection.Autofac;
|
||||
|
||||
namespace AutofacWebSite
|
||||
{
|
||||
|
|
@ -18,8 +18,7 @@ namespace AutofacWebSite
|
|||
services.AddTransient<HelloWorldBuilder>();
|
||||
|
||||
var builder = new ContainerBuilder();
|
||||
AutofacRegistration.Populate(builder,
|
||||
services);
|
||||
builder.Populate(services);
|
||||
|
||||
var container = builder.Build();
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,8 @@
|
|||
"kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5000"
|
||||
},
|
||||
"dependencies": {
|
||||
"Autofac": "3.3.0",
|
||||
"Autofac.Framework.DependencyInjection": "4.0.0-*",
|
||||
"Kestrel": "1.0.0-*",
|
||||
"Microsoft.Framework.DependencyInjection.Autofac": "1.0.0-*",
|
||||
"Microsoft.AspNet.Mvc": "6.0.0-*",
|
||||
"Microsoft.AspNet.Mvc.TestConfiguration": "1.0.0",
|
||||
"Microsoft.AspNet.Server.IIS": "1.0.0-*",
|
||||
|
|
@ -14,7 +13,8 @@
|
|||
"Microsoft.AspNet.StaticFiles": "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": { }
|
||||
"dnx451": { },
|
||||
"dnxcore50": { }
|
||||
},
|
||||
"webroot": "wwwroot"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue