React to GetDefaultServices/TryAdd changes
This commit is contained in:
parent
e7941b5a84
commit
27432d9453
|
|
@ -10,22 +10,19 @@ namespace Microsoft.Framework.DependencyInjection
|
||||||
{
|
{
|
||||||
public static class MvcServiceCollectionExtensions
|
public static class MvcServiceCollectionExtensions
|
||||||
{
|
{
|
||||||
public static IServiceCollection AddMvc(this IServiceCollection services)
|
public static IServiceCollection AddMvc(this IServiceCollection services, IConfiguration configuration = null)
|
||||||
{
|
{
|
||||||
ConfigureDefaultServices(services);
|
ConfigureDefaultServices(services, configuration);
|
||||||
return services.Add(MvcServices.GetDefaultServices());
|
services.TryAdd(MvcServices.GetDefaultServices(configuration));
|
||||||
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IServiceCollection AddMvc(this IServiceCollection services, IConfiguration configuration)
|
private static void ConfigureDefaultServices(IServiceCollection services, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
ConfigureDefaultServices(services);
|
services.AddOptions(configuration);
|
||||||
return services.Add(MvcServices.GetDefaultServices(configuration));
|
services.AddDataProtection(configuration);
|
||||||
}
|
services.AddRouting(configuration);
|
||||||
|
services.AddContextAccessor(configuration);
|
||||||
private static void ConfigureDefaultServices(IServiceCollection services)
|
|
||||||
{
|
|
||||||
services.Add(DataProtectionServices.GetDefaultServices());
|
|
||||||
services.Add(RoutingServices.GetDefaultServices());
|
|
||||||
services.Configure<RouteOptions>(routeOptions =>
|
services.Configure<RouteOptions>(routeOptions =>
|
||||||
routeOptions.ConstraintMap
|
routeOptions.ConstraintMap
|
||||||
.Add("exists",
|
.Add("exists",
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
public class MvcServices
|
public class MvcServices
|
||||||
{
|
{
|
||||||
public static IEnumerable<IServiceDescriptor> GetDefaultServices()
|
public static IEnumerable<IServiceDescriptor> GetDefaultServices(IConfiguration configuration = null)
|
||||||
{
|
|
||||||
return GetDefaultServices(new Configuration());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IEnumerable<IServiceDescriptor> GetDefaultServices(IConfiguration configuration)
|
|
||||||
{
|
{
|
||||||
var describe = new ServiceDescriber(configuration);
|
var describe = new ServiceDescriber(configuration);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ using Microsoft.CodeAnalysis.CSharp;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
using Microsoft.Framework.DependencyInjection.Fallback;
|
using Microsoft.Framework.DependencyInjection.Fallback;
|
||||||
using Microsoft.Framework.DependencyInjection.ServiceLookup;
|
using Microsoft.Framework.DependencyInjection.ServiceLookup;
|
||||||
using Microsoft.Framework.OptionsModel;
|
|
||||||
using Microsoft.Framework.Runtime;
|
using Microsoft.Framework.Runtime;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc
|
namespace Microsoft.AspNet.Mvc
|
||||||
|
|
@ -33,10 +32,9 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var appEnv = _appServices.GetRequiredService<IApplicationEnvironment>();
|
var appEnv = _appServices.GetRequiredService<IApplicationEnvironment>();
|
||||||
|
|
||||||
var setup = new RazorViewEngineOptionsSetup(appEnv);
|
var setup = new RazorViewEngineOptionsSetup(appEnv);
|
||||||
var accessor = new OptionsManager<RazorViewEngineOptions>(new[] { setup });
|
|
||||||
var sc = new ServiceCollection();
|
var sc = new ServiceCollection();
|
||||||
sc.AddInstance<IOptions<RazorViewEngineOptions>>(accessor);
|
sc.ConfigureOptions(setup);
|
||||||
sc.Add(MvcServices.GetDefaultServices());
|
sc.AddMvc();
|
||||||
|
|
||||||
var viewCompiler = new RazorPreCompiler(BuildFallbackServiceProvider(sc, _appServices));
|
var viewCompiler = new RazorPreCompiler(BuildFallbackServiceProvider(sc, _appServices));
|
||||||
viewCompiler.CompileViews(context);
|
viewCompiler.CompileViews(context);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue