React to options and hosting changes
This commit is contained in:
parent
1680616fe5
commit
448ac5a0dc
|
|
@ -31,7 +31,7 @@ namespace MvcSample.Web
|
||||||
{
|
{
|
||||||
app.UseMiddleware<MonitoringMiddlware>();
|
app.UseMiddleware<MonitoringMiddlware>();
|
||||||
|
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
services.AddMvc();
|
services.AddMvc();
|
||||||
services.AddSingleton<PassThroughAttribute>();
|
services.AddSingleton<PassThroughAttribute>();
|
||||||
|
|
@ -42,11 +42,11 @@ namespace MvcSample.Web
|
||||||
// sample's assemblies are loaded. This prevents loading controllers from other assemblies
|
// sample's assemblies are loaded. This prevents loading controllers from other assemblies
|
||||||
// when the sample is used in the Functional Tests.
|
// when the sample is used in the Functional Tests.
|
||||||
services.AddTransient<IAssemblyProvider, TestAssemblyProvider<Startup>>();
|
services.AddTransient<IAssemblyProvider, TestAssemblyProvider<Startup>>();
|
||||||
services.ConfigureOptions<MvcOptions>(options =>
|
services.Configure<MvcOptions>(options =>
|
||||||
{
|
{
|
||||||
options.Filters.Add(typeof(PassThroughAttribute), order: 17);
|
options.Filters.Add(typeof(PassThroughAttribute), order: 17);
|
||||||
});
|
});
|
||||||
services.ConfigureOptions<RazorViewEngineOptions>(options =>
|
services.Configure<RazorViewEngineOptions>(options =>
|
||||||
{
|
{
|
||||||
var expander = new LanguageViewLocationExpander(
|
var expander = new LanguageViewLocationExpander(
|
||||||
context => context.HttpContext.Request.Query["language"]);
|
context => context.HttpContext.Request.Query["language"]);
|
||||||
|
|
@ -72,7 +72,7 @@ namespace MvcSample.Web
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
services.AddMvc();
|
services.AddMvc();
|
||||||
services.AddSingleton<PassThroughAttribute>();
|
services.AddSingleton<PassThroughAttribute>();
|
||||||
|
|
@ -83,7 +83,7 @@ namespace MvcSample.Web
|
||||||
// when the sample is used in the Functional Tests.
|
// when the sample is used in the Functional Tests.
|
||||||
services.AddTransient<IAssemblyProvider, TestAssemblyProvider<Startup>>();
|
services.AddTransient<IAssemblyProvider, TestAssemblyProvider<Startup>>();
|
||||||
|
|
||||||
services.ConfigureOptions<MvcOptions>(options =>
|
services.Configure<MvcOptions>(options =>
|
||||||
{
|
{
|
||||||
options.Filters.Add(typeof(PassThroughAttribute), order: 17);
|
options.Filters.Add(typeof(PassThroughAttribute), order: 17);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
public AntiForgery([NotNull] IClaimUidExtractor claimUidExtractor,
|
public AntiForgery([NotNull] IClaimUidExtractor claimUidExtractor,
|
||||||
[NotNull] IDataProtectionProvider dataProtectionProvider,
|
[NotNull] IDataProtectionProvider dataProtectionProvider,
|
||||||
[NotNull] IAntiForgeryAdditionalDataProvider additionalDataProvider,
|
[NotNull] IAntiForgeryAdditionalDataProvider additionalDataProvider,
|
||||||
[NotNull] IOptionsAccessor<MvcOptions> mvcOptions)
|
[NotNull] IOptions<MvcOptions> mvcOptions)
|
||||||
{
|
{
|
||||||
var config = mvcOptions.Options.AntiForgeryOptions;
|
var config = mvcOptions.Options.AntiForgeryOptions;
|
||||||
var serializer = new AntiForgeryTokenSerializer(dataProtectionProvider.CreateProtector(_purpose));
|
var serializer = new AntiForgeryTokenSerializer(dataProtectionProvider.CreateProtector(_purpose));
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
public ControllerActionDescriptorProvider(IAssemblyProvider assemblyProvider,
|
public ControllerActionDescriptorProvider(IAssemblyProvider assemblyProvider,
|
||||||
IActionDiscoveryConventions conventions,
|
IActionDiscoveryConventions conventions,
|
||||||
IGlobalFilterProvider globalFilters,
|
IGlobalFilterProvider globalFilters,
|
||||||
IOptionsAccessor<MvcOptions> optionsAccessor)
|
IOptions<MvcOptions> optionsAccessor)
|
||||||
{
|
{
|
||||||
_assemblyProvider = assemblyProvider;
|
_assemblyProvider = assemblyProvider;
|
||||||
_conventions = conventions;
|
_conventions = conventions;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Mvc.Filters
|
||||||
/// Creates a new instance of <see cref="DefaultGlobalFilterProvider"/>.
|
/// Creates a new instance of <see cref="DefaultGlobalFilterProvider"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="optionsAccessor">The options accessor for <see cref="MvcOptions"/>.</param>
|
/// <param name="optionsAccessor">The options accessor for <see cref="MvcOptions"/>.</param>
|
||||||
public DefaultGlobalFilterProvider(IOptionsAccessor<MvcOptions> optionsAccessor)
|
public DefaultGlobalFilterProvider(IOptions<MvcOptions> optionsAccessor)
|
||||||
{
|
{
|
||||||
var filters = optionsAccessor.Options.Filters;
|
var filters = optionsAccessor.Options.Filters;
|
||||||
_filters = filters.ToList();
|
_filters = filters.ToList();
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ namespace Microsoft.AspNet.Mvc.OptionDescriptors
|
||||||
/// <param name="typeActivator">An <see cref="ITypeActivator"/> instance used to instantiate types.</param>
|
/// <param name="typeActivator">An <see cref="ITypeActivator"/> instance used to instantiate types.</param>
|
||||||
/// <param name="serviceProvider">A <see cref="IServiceProvider"/> instance that retrieves services from the
|
/// <param name="serviceProvider">A <see cref="IServiceProvider"/> instance that retrieves services from the
|
||||||
/// service collection.</param>
|
/// service collection.</param>
|
||||||
public DefaultInputFormattersProvider(IOptionsAccessor<MvcOptions> optionsAccessor,
|
public DefaultInputFormattersProvider(IOptions<MvcOptions> optionsAccessor,
|
||||||
ITypeActivator typeActivator,
|
ITypeActivator typeActivator,
|
||||||
IServiceProvider serviceProvider)
|
IServiceProvider serviceProvider)
|
||||||
: base(optionsAccessor.Options.InputFormatters, typeActivator, serviceProvider)
|
: base(optionsAccessor.Options.InputFormatters, typeActivator, serviceProvider)
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <param name="typeActivator">An <see cref="ITypeActivator"/> instance used to instantiate types.</param>
|
/// <param name="typeActivator">An <see cref="ITypeActivator"/> instance used to instantiate types.</param>
|
||||||
/// <param name="serviceProvider">A <see cref="IServiceProvider"/> instance that retrieves services from the
|
/// <param name="serviceProvider">A <see cref="IServiceProvider"/> instance that retrieves services from the
|
||||||
/// service collection.</param>
|
/// service collection.</param>
|
||||||
public DefaultOutputFormattersProvider(IOptionsAccessor<MvcOptions> optionsAccessor,
|
public DefaultOutputFormattersProvider(IOptions<MvcOptions> optionsAccessor,
|
||||||
ITypeActivator typeActivator,
|
ITypeActivator typeActivator,
|
||||||
IServiceProvider serviceProvider)
|
IServiceProvider serviceProvider)
|
||||||
: base(optionsAccessor.Options.OutputFormatters, typeActivator, serviceProvider)
|
: base(optionsAccessor.Options.OutputFormatters, typeActivator, serviceProvider)
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ namespace Microsoft.AspNet.Mvc.Internal
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException(Resources.FormatUnableToFindServices(
|
throw new InvalidOperationException(Resources.FormatUnableToFindServices(
|
||||||
"IServiceCollection.AddMvc()",
|
"IServiceCollection.AddMvc()",
|
||||||
"IApplicationBuilder.UsePerRequestServices(...)",
|
"IApplicationBuilder.UseServices(...)",
|
||||||
"IApplicationBuilder.UseMvc(...)"));
|
"IApplicationBuilder.UseMvc(...)"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
var actionContext = new ActionContext(context.HttpContext, context.RouteData, actionDescriptor);
|
var actionContext = new ActionContext(context.HttpContext, context.RouteData, actionDescriptor);
|
||||||
|
|
||||||
var optionsAccessor = services.GetService<IOptionsAccessor<MvcOptions>>();
|
var optionsAccessor = services.GetService<IOptions<MvcOptions>>();
|
||||||
actionContext.ModelState.MaxAllowedErrors = optionsAccessor.Options.MaxModelValidationErrors;
|
actionContext.ModelState.MaxAllowedErrors = optionsAccessor.Options.MaxModelValidationErrors;
|
||||||
|
|
||||||
var contextAccessor = services.GetService<IContextAccessor<ActionContext>>();
|
var contextAccessor = services.GetService<IContextAccessor<ActionContext>>();
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ namespace Microsoft.AspNet.Mvc.OptionDescriptors
|
||||||
/// <param name="serviceProvider">A <see cref="IServiceProvider"/> instance that retrieves services from the
|
/// <param name="serviceProvider">A <see cref="IServiceProvider"/> instance that retrieves services from the
|
||||||
/// service collection.</param>
|
/// service collection.</param>
|
||||||
public DefaultModelBindersProvider(
|
public DefaultModelBindersProvider(
|
||||||
IOptionsAccessor<MvcOptions> optionsAccessor,
|
IOptions<MvcOptions> optionsAccessor,
|
||||||
ITypeActivator typeActivator,
|
ITypeActivator typeActivator,
|
||||||
IServiceProvider serviceProvider)
|
IServiceProvider serviceProvider)
|
||||||
: base(optionsAccessor.Options.ModelBinders, typeActivator, serviceProvider)
|
: base(optionsAccessor.Options.ModelBinders, typeActivator, serviceProvider)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Mvc.OptionDescriptors
|
||||||
/// <param name="serviceProvider">A <see cref="IServiceProvider"/> instance that retrieves services from the
|
/// <param name="serviceProvider">A <see cref="IServiceProvider"/> instance that retrieves services from the
|
||||||
/// service collection.</param>
|
/// service collection.</param>
|
||||||
public DefaultModelValidatorProviderProvider(
|
public DefaultModelValidatorProviderProvider(
|
||||||
IOptionsAccessor<MvcOptions> optionsAccessor,
|
IOptions<MvcOptions> optionsAccessor,
|
||||||
ITypeActivator typeActivator,
|
ITypeActivator typeActivator,
|
||||||
IServiceProvider serviceProvider)
|
IServiceProvider serviceProvider)
|
||||||
: base(optionsAccessor.Options.ModelValidatorProviders, typeActivator, serviceProvider)
|
: base(optionsAccessor.Options.ModelValidatorProviders, typeActivator, serviceProvider)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Mvc.OptionDescriptors
|
||||||
/// <param name="serviceProvider">A <see cref="IServiceProvider"/> instance that retrieves services from the
|
/// <param name="serviceProvider">A <see cref="IServiceProvider"/> instance that retrieves services from the
|
||||||
/// service collection.</param>
|
/// service collection.</param>
|
||||||
public DefaultValueProviderFactoryProvider(
|
public DefaultValueProviderFactoryProvider(
|
||||||
IOptionsAccessor<MvcOptions> optionsAccessor,
|
IOptions<MvcOptions> optionsAccessor,
|
||||||
ITypeActivator typeActivator,
|
ITypeActivator typeActivator,
|
||||||
IServiceProvider serviceProvider)
|
IServiceProvider serviceProvider)
|
||||||
: base(optionsAccessor.Options.ValueProviderFactories, typeActivator, serviceProvider)
|
: base(optionsAccessor.Options.ValueProviderFactories, typeActivator, serviceProvider)
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ namespace Microsoft.AspNet.Mvc.OptionDescriptors
|
||||||
/// <param name="serviceProvider">A <see cref="IServiceProvider"/> instance that retrieves services from the
|
/// <param name="serviceProvider">A <see cref="IServiceProvider"/> instance that retrieves services from the
|
||||||
/// service collection.</param>
|
/// service collection.</param>
|
||||||
public DefaultViewEngineProvider(
|
public DefaultViewEngineProvider(
|
||||||
IOptionsAccessor<MvcOptions> optionsAccessor,
|
IOptions<MvcOptions> optionsAccessor,
|
||||||
ITypeActivator typeActivator,
|
ITypeActivator typeActivator,
|
||||||
IServiceProvider serviceProvider)
|
IServiceProvider serviceProvider)
|
||||||
: base(optionsAccessor.Options.ViewEngines, typeActivator, serviceProvider)
|
: base(optionsAccessor.Options.ViewEngines, typeActivator, serviceProvider)
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
private readonly TimeSpan _offset;
|
private readonly TimeSpan _offset;
|
||||||
|
|
||||||
public ExpiringFileInfoCache(IOptionsAccessor<RazorViewEngineOptions> optionsAccessor)
|
public ExpiringFileInfoCache(IOptions<RazorViewEngineOptions> optionsAccessor)
|
||||||
{
|
{
|
||||||
_fileSystem = optionsAccessor.Options.FileSystem;
|
_fileSystem = optionsAccessor.Options.FileSystem;
|
||||||
_offset = optionsAccessor.Options.ExpirationBeforeCheckingFilesOnDisk;
|
_offset = optionsAccessor.Options.ExpirationBeforeCheckingFilesOnDisk;
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace Microsoft.AspNet.Mvc.Razor.OptionDescriptors
|
||||||
/// <param name="serviceProvider">A <see cref="IServiceProvider"/> instance that retrieves services from the
|
/// <param name="serviceProvider">A <see cref="IServiceProvider"/> instance that retrieves services from the
|
||||||
/// service collection.</param>
|
/// service collection.</param>
|
||||||
public DefaultViewLocationExpanderProvider(
|
public DefaultViewLocationExpanderProvider(
|
||||||
IOptionsAccessor<RazorViewEngineOptions> optionsAccessor,
|
IOptions<RazorViewEngineOptions> optionsAccessor,
|
||||||
ITypeActivator typeActivator,
|
ITypeActivator typeActivator,
|
||||||
IServiceProvider serviceProvider)
|
IServiceProvider serviceProvider)
|
||||||
: base(optionsAccessor.Options.ViewLocationExpanders, typeActivator, serviceProvider)
|
: base(optionsAccessor.Options.ViewLocationExpanders, typeActivator, serviceProvider)
|
||||||
|
|
|
||||||
|
|
@ -22,13 +22,13 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
public RazorPreCompiler([NotNull] IServiceProvider designTimeServiceProvider) :
|
public RazorPreCompiler([NotNull] IServiceProvider designTimeServiceProvider) :
|
||||||
this(designTimeServiceProvider,
|
this(designTimeServiceProvider,
|
||||||
designTimeServiceProvider.GetService<IMvcRazorHost>(),
|
designTimeServiceProvider.GetService<IMvcRazorHost>(),
|
||||||
designTimeServiceProvider.GetService<IOptionsAccessor<RazorViewEngineOptions>>())
|
designTimeServiceProvider.GetService<IOptions<RazorViewEngineOptions>>())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public RazorPreCompiler([NotNull] IServiceProvider designTimeServiceProvider,
|
public RazorPreCompiler([NotNull] IServiceProvider designTimeServiceProvider,
|
||||||
[NotNull] IMvcRazorHost host,
|
[NotNull] IMvcRazorHost host,
|
||||||
[NotNull] IOptionsAccessor<RazorViewEngineOptions> optionsAccessor)
|
[NotNull] IOptions<RazorViewEngineOptions> optionsAccessor)
|
||||||
{
|
{
|
||||||
_serviceProvider = designTimeServiceProvider;
|
_serviceProvider = designTimeServiceProvider;
|
||||||
_host = host;
|
_host = host;
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
private readonly IRazorPageFactory _pageFactory;
|
private readonly IRazorPageFactory _pageFactory;
|
||||||
|
|
||||||
public ViewStartProvider(IRazorPageFactory pageFactory,
|
public ViewStartProvider(IRazorPageFactory pageFactory,
|
||||||
IOptionsAccessor<RazorViewEngineOptions> optionsAccessor)
|
IOptions<RazorViewEngineOptions> optionsAccessor)
|
||||||
{
|
{
|
||||||
_fileSystem = optionsAccessor.Options.FileSystem;
|
_fileSystem = optionsAccessor.Options.FileSystem;
|
||||||
_pageFactory = pageFactory;
|
_pageFactory = pageFactory;
|
||||||
|
|
|
||||||
|
|
@ -214,7 +214,7 @@ namespace System.Net.Http
|
||||||
if (formatters == null)
|
if (formatters == null)
|
||||||
{
|
{
|
||||||
// Get the default formatters from options
|
// Get the default formatters from options
|
||||||
var options = context.RequestServices.GetService<IOptionsAccessor<WebApiCompatShimOptions>>();
|
var options = context.RequestServices.GetService<IOptions<WebApiCompatShimOptions>>();
|
||||||
formatters = options.Options.Formatters;
|
formatters = options.Options.Formatters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -266,7 +266,7 @@ namespace System.Net.Http
|
||||||
var context = GetHttpContext(request);
|
var context = GetHttpContext(request);
|
||||||
|
|
||||||
// Get the default formatters from options
|
// Get the default formatters from options
|
||||||
var options = context.RequestServices.GetService<IOptionsAccessor<WebApiCompatShimOptions>>();
|
var options = context.RequestServices.GetService<IOptions<WebApiCompatShimOptions>>();
|
||||||
var formatters = options.Options.Formatters;
|
var formatters = options.Options.Formatters;
|
||||||
|
|
||||||
var formatter = formatters.FindWriter(typeof(T), mediaType);
|
var formatter = formatters.FindWriter(typeof(T), mediaType);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ using Microsoft.Framework.OptionsModel;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.WebApiCompatShim
|
namespace Microsoft.AspNet.Mvc.WebApiCompatShim
|
||||||
{
|
{
|
||||||
public class WebApiCompatShimOptionsSetup : IOptionsAction<MvcOptions>, IOptionsAction<WebApiCompatShimOptions>
|
public class WebApiCompatShimOptionsSetup : IConfigureOptions<MvcOptions>, IConfigureOptions<WebApiCompatShimOptions>
|
||||||
{
|
{
|
||||||
public readonly static string DefaultAreaName = "api";
|
public readonly static string DefaultAreaName = "api";
|
||||||
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
public void Invoke(MvcOptions options)
|
public void Configure(MvcOptions options, string name = "")
|
||||||
{
|
{
|
||||||
// Add webapi behaviors to controllers with the appropriate attributes
|
// Add webapi behaviors to controllers with the appropriate attributes
|
||||||
options.ApplicationModelConventions.Add(new WebApiActionConventionsGlobalModelConvention());
|
options.ApplicationModelConventions.Add(new WebApiActionConventionsGlobalModelConvention());
|
||||||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Mvc.WebApiCompatShim
|
||||||
options.OutputFormatters.Insert(0, new HttpResponseMessageOutputFormatter());
|
options.OutputFormatters.Insert(0, new HttpResponseMessageOutputFormatter());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Invoke(WebApiCompatShimOptions options)
|
public void Configure(WebApiCompatShimOptions options, string name = "")
|
||||||
{
|
{
|
||||||
// Add the default formatters
|
// Add the default formatters
|
||||||
options.Formatters.AddRange(new MediaTypeFormatterCollection());
|
options.Formatters.AddRange(new MediaTypeFormatterCollection());
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ namespace Microsoft.Framework.DependencyInjection
|
||||||
{
|
{
|
||||||
public static IServiceCollection AddWebApiConventions(this IServiceCollection services)
|
public static IServiceCollection AddWebApiConventions(this IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddOptionsAction<WebApiCompatShimOptionsSetup>();
|
services.ConfigureOptions<WebApiCompatShimOptionsSetup>();
|
||||||
|
|
||||||
// The constructors on DefaultContentNegotiator aren't DI friendly, so just
|
// The constructors on DefaultContentNegotiator aren't DI friendly, so just
|
||||||
// new it up.
|
// new it up.
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets up default options for <see cref="MvcOptions"/>.
|
/// Sets up default options for <see cref="MvcOptions"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MvcOptionsSetup : OptionsAction<MvcOptions>
|
public class MvcOptionsSetup : ConfigureOptions<MvcOptions>
|
||||||
{
|
{
|
||||||
/// <remarks>Sets the Order to -1 to allow MvcOptionsSetup to run before a user call to ConfigureOptions.</remarks>
|
/// <remarks>Sets the Order to -1 to allow MvcOptionsSetup to run before a user call to ConfigureOptions.</remarks>
|
||||||
public MvcOptionsSetup() : base(ConfigureMvc)
|
public MvcOptionsSetup() : base(ConfigureMvc)
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.Framework.DependencyInjection
|
||||||
|
|
||||||
private static void AddMvcRouteOptions(IServiceCollection services)
|
private static void AddMvcRouteOptions(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.ConfigureOptions<RouteOptions>(routeOptions =>
|
services.Configure<RouteOptions>(routeOptions =>
|
||||||
routeOptions.ConstraintMap
|
routeOptions.ConstraintMap
|
||||||
.Add("exists",
|
.Add("exists",
|
||||||
typeof(KnownRouteValueConstraint)));
|
typeof(KnownRouteValueConstraint)));
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
//
|
//
|
||||||
// Options and core services.
|
// Options and core services.
|
||||||
//
|
//
|
||||||
yield return describe.Transient<IOptionsAction<MvcOptions>, MvcOptionsSetup>();
|
yield return describe.Transient<IConfigureOptions<MvcOptions>, MvcOptionsSetup>();
|
||||||
yield return describe.Transient<IOptionsAction<RazorViewEngineOptions>, RazorViewEngineOptionsSetup>();
|
yield return describe.Transient<IConfigureOptions<RazorViewEngineOptions>, RazorViewEngineOptionsSetup>();
|
||||||
|
|
||||||
yield return describe.Transient<IAssemblyProvider, DefaultAssemblyProvider>();
|
yield return describe.Transient<IAssemblyProvider, DefaultAssemblyProvider>();
|
||||||
yield return describe.Transient(typeof(INestedProviderManager<>), typeof(NestedProviderManager<>));
|
yield return describe.Transient(typeof(INestedProviderManager<>), typeof(NestedProviderManager<>));
|
||||||
yield return describe.Transient(typeof(INestedProviderManagerAsync<>), typeof(NestedProviderManagerAsync<>));
|
yield return describe.Transient(typeof(INestedProviderManagerAsync<>), typeof(NestedProviderManagerAsync<>));
|
||||||
|
|
@ -110,7 +109,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
// The host is designed to be discarded after consumption and is very inexpensive to initialize.
|
// The host is designed to be discarded after consumption and is very inexpensive to initialize.
|
||||||
yield return describe.Transient<IMvcRazorHost>(serviceProvider =>
|
yield return describe.Transient<IMvcRazorHost>(serviceProvider =>
|
||||||
{
|
{
|
||||||
var optionsAccessor = serviceProvider.GetService<IOptionsAccessor<RazorViewEngineOptions>>();
|
var optionsAccessor = serviceProvider.GetService<IOptions<RazorViewEngineOptions>>();
|
||||||
return new MvcRazorHost(optionsAccessor.Options.FileSystem);
|
return new MvcRazorHost(optionsAccessor.Options.FileSystem);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
= new ResourceManager("Microsoft.AspNet.Mvc.Resources", typeof(Resources).GetTypeInfo().Assembly);
|
= new ResourceManager("Microsoft.AspNet.Mvc.Resources", typeof(Resources).GetTypeInfo().Assembly);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unable to find the required services. Please add all the required services by calling AddMvc() before calling UseMvc()/UsePerRequestServices() in the Application Startup.
|
/// Unable to find the required services. Please add all the required services by calling AddMvc() before calling UseMvc()/UseServices() in the Application Startup.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string UnableToFindServices
|
internal static string UnableToFindServices
|
||||||
{
|
{
|
||||||
|
|
@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unable to find the required services. Please add all the required services by calling AddMvc() before calling UseMvc()/UsePerRequestServices() in the Application Startup.
|
/// Unable to find the required services. Please add all the required services by calling AddMvc() before calling UseMvc()/UseServices() in the Application Startup.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string FormatUnableToFindServices()
|
internal static string FormatUnableToFindServices()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var appEnv = _appServices.GetService<IApplicationEnvironment>();
|
var appEnv = _appServices.GetService<IApplicationEnvironment>();
|
||||||
|
|
||||||
var setup = new RazorViewEngineOptionsSetup(appEnv);
|
var setup = new RazorViewEngineOptionsSetup(appEnv);
|
||||||
var accessor = new OptionsAccessor<RazorViewEngineOptions>(new[] { setup });
|
var accessor = new OptionsManager<RazorViewEngineOptions>(new[] { setup });
|
||||||
sc.AddInstance<IOptionsAccessor<RazorViewEngineOptions>>(accessor);
|
sc.AddInstance<IOptions<RazorViewEngineOptions>>(accessor);
|
||||||
sc.Add(MvcServices.GetDefaultServices());
|
sc.Add(MvcServices.GetDefaultServices());
|
||||||
var sp = sc.BuildServiceProvider(_appServices);
|
var sp = sc.BuildServiceProvider(_appServices);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets up default options for <see cref="RazorViewEngineOptions"/>.
|
/// Sets up default options for <see cref="RazorViewEngineOptions"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class RazorViewEngineOptionsSetup : OptionsAction<RazorViewEngineOptions>
|
public class RazorViewEngineOptionsSetup : ConfigureOptions<RazorViewEngineOptions>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of <see cref="RazorViewEngineOptions"/>.
|
/// Initializes a new instance of <see cref="RazorViewEngineOptions"/>.
|
||||||
|
|
|
||||||
|
|
@ -521,12 +521,12 @@ namespace Microsoft.AspNet.Mvc.Core.Test.ActionResults
|
||||||
{
|
{
|
||||||
var optionsSetup = new MvcOptionsSetup();
|
var optionsSetup = new MvcOptionsSetup();
|
||||||
var options = new MvcOptions();
|
var options = new MvcOptions();
|
||||||
optionsSetup.Invoke(options);
|
optionsSetup.Configure(options);
|
||||||
var optionsAccessor = new Mock<IOptionsAccessor<MvcOptions>>();
|
var optionsAccessor = new Mock<IOptions<MvcOptions>>();
|
||||||
optionsAccessor.SetupGet(o => o.Options).Returns(options);
|
optionsAccessor.SetupGet(o => o.Options).Returns(options);
|
||||||
|
|
||||||
var serviceCollection = new ServiceCollection();
|
var serviceCollection = new ServiceCollection();
|
||||||
serviceCollection.AddInstance<IOptionsAccessor<MvcOptions>>(optionsAccessor.Object);
|
serviceCollection.AddInstance<IOptions<MvcOptions>>(optionsAccessor.Object);
|
||||||
return serviceCollection.BuildServiceProvider();
|
return serviceCollection.BuildServiceProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
var claimExtractor = new Mock<IClaimUidExtractor>();
|
var claimExtractor = new Mock<IClaimUidExtractor>();
|
||||||
var dataProtectionProvider = new Mock<IDataProtectionProvider>();
|
var dataProtectionProvider = new Mock<IDataProtectionProvider>();
|
||||||
var additionalDataProvider = new Mock<IAntiForgeryAdditionalDataProvider>();
|
var additionalDataProvider = new Mock<IAntiForgeryAdditionalDataProvider>();
|
||||||
var optionsAccessor = new Mock<IOptionsAccessor<MvcOptions>>();
|
var optionsAccessor = new Mock<IOptions<MvcOptions>>();
|
||||||
optionsAccessor.SetupGet(o => o.Options).Returns(new MvcOptions());
|
optionsAccessor.SetupGet(o => o.Options).Returns(new MvcOptions());
|
||||||
return new AntiForgery(claimExtractor.Object,
|
return new AntiForgery(claimExtractor.Object,
|
||||||
dataProtectionProvider.Object,
|
dataProtectionProvider.Object,
|
||||||
|
|
|
||||||
|
|
@ -1369,7 +1369,7 @@ namespace Microsoft.AspNet.Mvc.Test
|
||||||
|
|
||||||
private ControllerActionDescriptorProvider GetProvider(
|
private ControllerActionDescriptorProvider GetProvider(
|
||||||
TypeInfo type,
|
TypeInfo type,
|
||||||
IOptionsAccessor<MvcOptions> options)
|
IOptions<MvcOptions> options)
|
||||||
{
|
{
|
||||||
var conventions = new StaticActionDiscoveryConventions(type);
|
var conventions = new StaticActionDiscoveryConventions(type);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -131,8 +131,8 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var mvcOptions = new MvcOptions();
|
var mvcOptions = new MvcOptions();
|
||||||
var setup = new MvcOptionsSetup();
|
var setup = new MvcOptionsSetup();
|
||||||
|
|
||||||
setup.Invoke(mvcOptions);
|
setup.Configure(mvcOptions);
|
||||||
var accessor = new Mock<IOptionsAccessor<MvcOptions>>();
|
var accessor = new Mock<IOptions<MvcOptions>>();
|
||||||
accessor.SetupGet(a => a.Options)
|
accessor.SetupGet(a => a.Options)
|
||||||
.Returns(mvcOptions);
|
.Returns(mvcOptions);
|
||||||
var validatorProvider = new DefaultModelValidatorProviderProvider(
|
var validatorProvider = new DefaultModelValidatorProviderProvider(
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
services.Setup(o => o.GetService(typeof(IEnumerable<MvcMarkerService>)))
|
services.Setup(o => o.GetService(typeof(IEnumerable<MvcMarkerService>)))
|
||||||
.Returns(new List<MvcMarkerService>());
|
.Returns(new List<MvcMarkerService>());
|
||||||
var expectedMessage = "Unable to find the required services. Please add all the required " +
|
var expectedMessage = "Unable to find the required services. Please add all the required " +
|
||||||
"services by calling 'IServiceCollection.AddMvc()' inside the call to 'IApplicationBuilder.UsePerRequestServices(...)' " +
|
"services by calling 'IServiceCollection.AddMvc()' inside the call to 'IApplicationBuilder.UseServices(...)' " +
|
||||||
"or 'IApplicationBuilder.UseMvc(...)' in the application startup code.";
|
"or 'IApplicationBuilder.UseMvc(...)' in the application startup code.";
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ using Microsoft.Framework.OptionsModel;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc
|
namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
public class MockMvcOptionsAccessor : IOptionsAccessor<MvcOptions>
|
public class MockMvcOptionsAccessor : IOptions<MvcOptions>
|
||||||
{
|
{
|
||||||
public MockMvcOptionsAccessor()
|
public MockMvcOptionsAccessor()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var expected = 199;
|
var expected = 199;
|
||||||
var optionsAccessor = new Mock<IOptionsAccessor<MvcOptions>>();
|
var optionsAccessor = new Mock<IOptions<MvcOptions>>();
|
||||||
var options = new MvcOptions
|
var options = new MvcOptions
|
||||||
{
|
{
|
||||||
MaxModelValidationErrors = expected
|
MaxModelValidationErrors = expected
|
||||||
|
|
@ -167,7 +167,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
IActionSelector actionSelector = null,
|
IActionSelector actionSelector = null,
|
||||||
IActionInvokerFactory invokerFactory = null,
|
IActionInvokerFactory invokerFactory = null,
|
||||||
ILoggerFactory loggerFactory = null,
|
ILoggerFactory loggerFactory = null,
|
||||||
IOptionsAccessor<MvcOptions> optionsAccessor = null)
|
IOptions<MvcOptions> optionsAccessor = null)
|
||||||
{
|
{
|
||||||
var mockContextAccessor = new Mock<IContextAccessor<ActionContext>>();
|
var mockContextAccessor = new Mock<IContextAccessor<ActionContext>>();
|
||||||
mockContextAccessor.Setup(c => c.SetContextSource(
|
mockContextAccessor.Setup(c => c.SetContextSource(
|
||||||
|
|
@ -207,7 +207,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
|
|
||||||
if (optionsAccessor == null)
|
if (optionsAccessor == null)
|
||||||
{
|
{
|
||||||
var mockOptionsAccessor = new Mock<IOptionsAccessor<MvcOptions>>();
|
var mockOptionsAccessor = new Mock<IOptions<MvcOptions>>();
|
||||||
mockOptionsAccessor.SetupGet(o => o.Options)
|
mockOptionsAccessor.SetupGet(o => o.Options)
|
||||||
.Returns(new MvcOptions());
|
.Returns(new MvcOptions());
|
||||||
|
|
||||||
|
|
@ -225,7 +225,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
.Returns(loggerFactory);
|
.Returns(loggerFactory);
|
||||||
httpContext.Setup(h => h.RequestServices.GetService(typeof(IEnumerable<MvcMarkerService>)))
|
httpContext.Setup(h => h.RequestServices.GetService(typeof(IEnumerable<MvcMarkerService>)))
|
||||||
.Returns(new List<MvcMarkerService> { new MvcMarkerService() });
|
.Returns(new List<MvcMarkerService> { new MvcMarkerService() });
|
||||||
httpContext.Setup(h => h.RequestServices.GetService(typeof(IOptionsAccessor<MvcOptions>)))
|
httpContext.Setup(h => h.RequestServices.GetService(typeof(IOptions<MvcOptions>)))
|
||||||
.Returns(optionsAccessor);
|
.Returns(optionsAccessor);
|
||||||
|
|
||||||
return new RouteContext(httpContext.Object);
|
return new RouteContext(httpContext.Object);
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace Microsoft.AspNet.Mvc.OptionDescriptors
|
||||||
var options = new MvcOptions();
|
var options = new MvcOptions();
|
||||||
options.ModelBinders.Add(binder);
|
options.ModelBinders.Add(binder);
|
||||||
options.ModelBinders.Add(typeof(TestModelBinder));
|
options.ModelBinders.Add(typeof(TestModelBinder));
|
||||||
var optionsAccessor = new Mock<IOptionsAccessor<MvcOptions>>();
|
var optionsAccessor = new Mock<IOptions<MvcOptions>>();
|
||||||
optionsAccessor.SetupGet(o => o.Options)
|
optionsAccessor.SetupGet(o => o.Options)
|
||||||
.Returns(options);
|
.Returns(options);
|
||||||
var activator = new TypeActivator();
|
var activator = new TypeActivator();
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ namespace Microsoft.AspNet.Mvc.OptionDescriptors
|
||||||
var options = new MvcOptions();
|
var options = new MvcOptions();
|
||||||
options.ModelValidatorProviders.Add(type);
|
options.ModelValidatorProviders.Add(type);
|
||||||
options.ModelValidatorProviders.Add(validationProvider);
|
options.ModelValidatorProviders.Add(validationProvider);
|
||||||
var accessor = new Mock<IOptionsAccessor<MvcOptions>>();
|
var accessor = new Mock<IOptions<MvcOptions>>();
|
||||||
accessor.SetupGet(a => a.Options)
|
accessor.SetupGet(a => a.Options)
|
||||||
.Returns(options);
|
.Returns(options);
|
||||||
var provider = new DefaultModelValidatorProviderProvider(accessor.Object,
|
var provider = new DefaultModelValidatorProviderProvider(accessor.Object,
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Mvc.OptionDescriptors
|
||||||
var options = new MvcOptions();
|
var options = new MvcOptions();
|
||||||
options.ValueProviderFactories.Add(valueProviderFactory);
|
options.ValueProviderFactories.Add(valueProviderFactory);
|
||||||
options.ValueProviderFactories.Add(type);
|
options.ValueProviderFactories.Add(type);
|
||||||
var accessor = new Mock<IOptionsAccessor<MvcOptions>>();
|
var accessor = new Mock<IOptions<MvcOptions>>();
|
||||||
accessor.SetupGet(a => a.Options)
|
accessor.SetupGet(a => a.Options)
|
||||||
.Returns(options);
|
.Returns(options);
|
||||||
var provider = new DefaultValueProviderFactoryProvider(accessor.Object,
|
var provider = new DefaultValueProviderFactoryProvider(accessor.Object,
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Mvc.OptionDescriptors
|
||||||
var options = new MvcOptions();
|
var options = new MvcOptions();
|
||||||
options.ViewEngines.Add(viewEngine);
|
options.ViewEngines.Add(viewEngine);
|
||||||
options.ViewEngines.Add(type);
|
options.ViewEngines.Add(type);
|
||||||
var accessor = new Mock<IOptionsAccessor<MvcOptions>>();
|
var accessor = new Mock<IOptions<MvcOptions>>();
|
||||||
accessor.SetupGet(a => a.Options)
|
accessor.SetupGet(a => a.Options)
|
||||||
.Returns(options);
|
.Returns(options);
|
||||||
var provider = new DefaultViewEngineProvider(accessor.Object, typeActivator, serviceProvider.Object);
|
var provider = new DefaultViewEngineProvider(accessor.Object, typeActivator, serviceProvider.Object);
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ namespace Microsoft.AspNet.Mvc.Rendering
|
||||||
var claimExtractor = new Mock<IClaimUidExtractor>();
|
var claimExtractor = new Mock<IClaimUidExtractor>();
|
||||||
var dataProtectionProvider = new Mock<IDataProtectionProvider>();
|
var dataProtectionProvider = new Mock<IDataProtectionProvider>();
|
||||||
var additionalDataProvider = new Mock<IAntiForgeryAdditionalDataProvider>();
|
var additionalDataProvider = new Mock<IAntiForgeryAdditionalDataProvider>();
|
||||||
var optionsAccessor = new Mock<IOptionsAccessor<MvcOptions>>();
|
var optionsAccessor = new Mock<IOptions<MvcOptions>>();
|
||||||
optionsAccessor.SetupGet(o => o.Options).Returns(new MvcOptions());
|
optionsAccessor.SetupGet(o => o.Options).Returns(new MvcOptions());
|
||||||
return new AntiForgery(claimExtractor.Object,
|
return new AntiForgery(claimExtractor.Object,
|
||||||
dataProtectionProvider.Object,
|
dataProtectionProvider.Object,
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
|
|
||||||
private static decimal Compute(string template)
|
private static decimal Compute(string template)
|
||||||
{
|
{
|
||||||
var options = new Mock<IOptionsAccessor<RouteOptions>>();
|
var options = new Mock<IOptions<RouteOptions>>();
|
||||||
options.SetupGet(o => o.Options).Returns(new RouteOptions());
|
options.SetupGet(o => o.Options).Returns(new RouteOptions());
|
||||||
|
|
||||||
var constraintResolver = new DefaultInlineConstraintResolver(
|
var constraintResolver = new DefaultInlineConstraintResolver(
|
||||||
|
|
|
||||||
|
|
@ -1211,7 +1211,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
var services = Mock.Of<IServiceProvider>();
|
var services = Mock.Of<IServiceProvider>();
|
||||||
|
|
||||||
var options = new RouteOptions();
|
var options = new RouteOptions();
|
||||||
var optionsMock = new Mock<IOptionsAccessor<RouteOptions>>();
|
var optionsMock = new Mock<IOptions<RouteOptions>>();
|
||||||
optionsMock.SetupGet(o => o.Options).Returns(options);
|
optionsMock.SetupGet(o => o.Options).Returns(options);
|
||||||
|
|
||||||
return new DefaultInlineConstraintResolver(services, optionsMock.Object);
|
return new DefaultInlineConstraintResolver(services, optionsMock.Object);
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ namespace Microsoft.AspNet.Mvc.Routing
|
||||||
.Setup(s => s.GetService(typeof(IActionDescriptorsCollectionProvider)))
|
.Setup(s => s.GetService(typeof(IActionDescriptorsCollectionProvider)))
|
||||||
.Returns(actionDescriptorProvider.Object);
|
.Returns(actionDescriptorProvider.Object);
|
||||||
|
|
||||||
var routeOptions = new Mock<IOptionsAccessor<RouteOptions>>();
|
var routeOptions = new Mock<IOptions<RouteOptions>>();
|
||||||
routeOptions
|
routeOptions
|
||||||
.SetupGet(o => o.Options)
|
.SetupGet(o => o.Options)
|
||||||
.Returns(new RouteOptions());
|
.Returns(new RouteOptions());
|
||||||
|
|
|
||||||
|
|
@ -641,7 +641,7 @@ namespace Microsoft.AspNet.Mvc.Core.Test
|
||||||
.Returns<VirtualPathContext>(rc => null);
|
.Returns<VirtualPathContext>(rc => null);
|
||||||
rt.DefaultHandler = target.Object;
|
rt.DefaultHandler = target.Object;
|
||||||
var serviceProviderMock = new Mock<IServiceProvider>();
|
var serviceProviderMock = new Mock<IServiceProvider>();
|
||||||
var accessorMock = new Mock<IOptionsAccessor<RouteOptions>>();
|
var accessorMock = new Mock<IOptions<RouteOptions>>();
|
||||||
accessorMock.SetupGet(o => o.Options).Returns(new RouteOptions());
|
accessorMock.SetupGet(o => o.Options).Returns(new RouteOptions());
|
||||||
serviceProviderMock.Setup(o => o.GetService(typeof(IInlineConstraintResolver)))
|
serviceProviderMock.Setup(o => o.GetService(typeof(IInlineConstraintResolver)))
|
||||||
.Returns(new DefaultInlineConstraintResolver(serviceProviderMock.Object,
|
.Returns(new DefaultInlineConstraintResolver(serviceProviderMock.Object,
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var expectedMessage = "Unable to find the required services. Please add all the required " +
|
var expectedMessage = "Unable to find the required services. Please add all the required " +
|
||||||
"services by calling 'IServiceCollection.AddMvc()' inside the call to 'IApplicationBuilder.UsePerRequestServices(...)' " +
|
"services by calling 'IServiceCollection.AddMvc()' inside the call to 'IApplicationBuilder.UseServices(...)' " +
|
||||||
"or 'IApplicationBuilder.UseMvc(...)' in the application startup code.";
|
"or 'IApplicationBuilder.UseMvc(...)' in the application startup code.";
|
||||||
|
|
||||||
// Act & Assert
|
// Act & Assert
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ using System.Linq;
|
||||||
using Microsoft.AspNet.Testing;
|
using Microsoft.AspNet.Testing;
|
||||||
using Moq;
|
using Moq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
using Microsoft.Framework.OptionsModel;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc.ModelBinding
|
namespace Microsoft.AspNet.Mvc.ModelBinding
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
|
|
||||||
public DummyFileSystem TestFileSystem { get; } = new DummyFileSystem();
|
public DummyFileSystem TestFileSystem { get; } = new DummyFileSystem();
|
||||||
|
|
||||||
public IOptionsAccessor<RazorViewEngineOptions> OptionsAccessor
|
public IOptions<RazorViewEngineOptions> OptionsAccessor
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|
@ -26,14 +26,14 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
FileSystem = TestFileSystem
|
FileSystem = TestFileSystem
|
||||||
};
|
};
|
||||||
|
|
||||||
var mock = new Mock<IOptionsAccessor<RazorViewEngineOptions>>(MockBehavior.Strict);
|
var mock = new Mock<IOptions<RazorViewEngineOptions>>(MockBehavior.Strict);
|
||||||
mock.Setup(oa => oa.Options).Returns(options);
|
mock.Setup(oa => oa.Options).Returns(options);
|
||||||
|
|
||||||
return mock.Object;
|
return mock.Object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ControllableExpiringFileInfoCache GetCache(IOptionsAccessor<RazorViewEngineOptions> optionsAccessor)
|
public ControllableExpiringFileInfoCache GetCache(IOptions<RazorViewEngineOptions> optionsAccessor)
|
||||||
{
|
{
|
||||||
return new ControllableExpiringFileInfoCache(optionsAccessor);
|
return new ControllableExpiringFileInfoCache(optionsAccessor);
|
||||||
}
|
}
|
||||||
|
|
@ -54,14 +54,14 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
cache.Sleep(offsetMilliseconds);
|
cache.Sleep(offsetMilliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Sleep(IOptionsAccessor<RazorViewEngineOptions> accessor, ControllableExpiringFileInfoCache cache, int offsetMilliSeconds)
|
public void Sleep(IOptions<RazorViewEngineOptions> accessor, ControllableExpiringFileInfoCache cache, int offsetMilliSeconds)
|
||||||
{
|
{
|
||||||
var baseMilliSeconds = (int)accessor.Options.ExpirationBeforeCheckingFilesOnDisk.TotalMilliseconds;
|
var baseMilliSeconds = (int)accessor.Options.ExpirationBeforeCheckingFilesOnDisk.TotalMilliseconds;
|
||||||
|
|
||||||
cache.Sleep(baseMilliSeconds + offsetMilliSeconds);
|
cache.Sleep(baseMilliSeconds + offsetMilliSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetExpiration(IOptionsAccessor<RazorViewEngineOptions> accessor, TimeSpan expiration)
|
public void SetExpiration(IOptions<RazorViewEngineOptions> accessor, TimeSpan expiration)
|
||||||
{
|
{
|
||||||
accessor.Options.ExpirationBeforeCheckingFilesOnDisk = expiration;
|
accessor.Options.ExpirationBeforeCheckingFilesOnDisk = expiration;
|
||||||
}
|
}
|
||||||
|
|
@ -307,7 +307,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
|
|
||||||
public class ControllableExpiringFileInfoCache : ExpiringFileInfoCache
|
public class ControllableExpiringFileInfoCache : ExpiringFileInfoCache
|
||||||
{
|
{
|
||||||
public ControllableExpiringFileInfoCache(IOptionsAccessor<RazorViewEngineOptions> optionsAccessor)
|
public ControllableExpiringFileInfoCache(IOptions<RazorViewEngineOptions> optionsAccessor)
|
||||||
: base(optionsAccessor)
|
: base(optionsAccessor)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Microsoft.AspNet.Mvc.Razor.OptionDescriptors
|
||||||
var options = new RazorViewEngineOptions();
|
var options = new RazorViewEngineOptions();
|
||||||
options.ViewLocationExpanders.Add(type);
|
options.ViewLocationExpanders.Add(type);
|
||||||
options.ViewLocationExpanders.Add(expander);
|
options.ViewLocationExpanders.Add(expander);
|
||||||
var accessor = new Mock<IOptionsAccessor<RazorViewEngineOptions>>();
|
var accessor = new Mock<IOptions<RazorViewEngineOptions>>();
|
||||||
accessor.SetupGet(a => a.Options)
|
accessor.SetupGet(a => a.Options)
|
||||||
.Returns(options);
|
.Returns(options);
|
||||||
var provider = new DefaultViewLocationExpanderProvider(accessor.Object,
|
var provider = new DefaultViewLocationExpanderProvider(accessor.Object,
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var setup = new MvcOptionsSetup();
|
var setup = new MvcOptionsSetup();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
setup.Invoke(mvcOptions);
|
setup.Configure(mvcOptions);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(1, mvcOptions.ViewEngines.Count);
|
Assert.Equal(1, mvcOptions.ViewEngines.Count);
|
||||||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var setup = new MvcOptionsSetup();
|
var setup = new MvcOptionsSetup();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
setup.Invoke(mvcOptions);
|
setup.Configure(mvcOptions);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(7, mvcOptions.ModelBinders.Count);
|
Assert.Equal(7, mvcOptions.ModelBinders.Count);
|
||||||
|
|
@ -53,7 +53,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var setup = new MvcOptionsSetup();
|
var setup = new MvcOptionsSetup();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
setup.Invoke(mvcOptions);
|
setup.Configure(mvcOptions);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
var valueProviders = mvcOptions.ValueProviderFactories;
|
var valueProviders = mvcOptions.ValueProviderFactories;
|
||||||
|
|
@ -71,7 +71,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var setup = new MvcOptionsSetup();
|
var setup = new MvcOptionsSetup();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
setup.Invoke(mvcOptions);
|
setup.Configure(mvcOptions);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(4, mvcOptions.OutputFormatters.Count);
|
Assert.Equal(4, mvcOptions.OutputFormatters.Count);
|
||||||
|
|
@ -89,7 +89,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var setup = new MvcOptionsSetup();
|
var setup = new MvcOptionsSetup();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
setup.Invoke(mvcOptions);
|
setup.Configure(mvcOptions);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(2, mvcOptions.InputFormatters.Count);
|
Assert.Equal(2, mvcOptions.InputFormatters.Count);
|
||||||
|
|
@ -105,7 +105,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var setup = new MvcOptionsSetup();
|
var setup = new MvcOptionsSetup();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
setup.Invoke(mvcOptions);
|
setup.Configure(mvcOptions);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(2, mvcOptions.ModelValidatorProviders.Count);
|
Assert.Equal(2, mvcOptions.ModelValidatorProviders.Count);
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ namespace Microsoft.AspNet.Mvc
|
||||||
var optionsSetup = new RazorViewEngineOptionsSetup(appEnv.Object);
|
var optionsSetup = new RazorViewEngineOptionsSetup(appEnv.Object);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
optionsSetup.Invoke(options);
|
optionsSetup.Configure(options);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.NotNull(options.FileSystem);
|
Assert.NotNull(options.FileSystem);
|
||||||
|
|
|
||||||
|
|
@ -267,9 +267,9 @@ namespace System.Web.Http
|
||||||
var options = new MvcOptions();
|
var options = new MvcOptions();
|
||||||
|
|
||||||
var setup = new WebApiCompatShimOptionsSetup();
|
var setup = new WebApiCompatShimOptionsSetup();
|
||||||
setup.Invoke(options);
|
setup.Configure(options);
|
||||||
|
|
||||||
var optionsAccessor = new Mock<IOptionsAccessor<MvcOptions>>();
|
var optionsAccessor = new Mock<IOptions<MvcOptions>>();
|
||||||
optionsAccessor
|
optionsAccessor
|
||||||
.SetupGet(o => o.Options)
|
.SetupGet(o => o.Options)
|
||||||
.Returns(options);
|
.Returns(options);
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,11 @@ namespace System.Net.Http
|
||||||
var options = new WebApiCompatShimOptions();
|
var options = new WebApiCompatShimOptions();
|
||||||
options.Formatters.AddRange(new MediaTypeFormatterCollection());
|
options.Formatters.AddRange(new MediaTypeFormatterCollection());
|
||||||
|
|
||||||
var optionsAccessor = new Mock<IOptionsAccessor<WebApiCompatShimOptions>>();
|
var optionsAccessor = new Mock<IOptions<WebApiCompatShimOptions>>();
|
||||||
optionsAccessor.SetupGet(o => o.Options).Returns(options);
|
optionsAccessor.SetupGet(o => o.Options).Returns(options);
|
||||||
|
|
||||||
services
|
services
|
||||||
.Setup(s => s.GetService(typeof(IOptionsAccessor<WebApiCompatShimOptions>)))
|
.Setup(s => s.GetService(typeof(IOptions<WebApiCompatShimOptions>)))
|
||||||
.Returns(optionsAccessor.Object);
|
.Returns(optionsAccessor.Object);
|
||||||
|
|
||||||
context.RequestServices = services.Object;
|
context.RequestServices = services.Object;
|
||||||
|
|
@ -63,11 +63,11 @@ namespace System.Net.Http
|
||||||
var options = new WebApiCompatShimOptions();
|
var options = new WebApiCompatShimOptions();
|
||||||
options.Formatters.AddRange(new MediaTypeFormatterCollection());
|
options.Formatters.AddRange(new MediaTypeFormatterCollection());
|
||||||
|
|
||||||
var optionsAccessor = new Mock<IOptionsAccessor<WebApiCompatShimOptions>>();
|
var optionsAccessor = new Mock<IOptions<WebApiCompatShimOptions>>();
|
||||||
optionsAccessor.SetupGet(o => o.Options).Returns(options);
|
optionsAccessor.SetupGet(o => o.Options).Returns(options);
|
||||||
|
|
||||||
services
|
services
|
||||||
.Setup(s => s.GetService(typeof(IOptionsAccessor<WebApiCompatShimOptions>)))
|
.Setup(s => s.GetService(typeof(IOptions<WebApiCompatShimOptions>)))
|
||||||
.Returns(optionsAccessor.Object);
|
.Returns(optionsAccessor.Object);
|
||||||
|
|
||||||
context.RequestServices = services.Object;
|
context.RequestServices = services.Object;
|
||||||
|
|
@ -326,12 +326,12 @@ namespace System.Net.Http
|
||||||
options.Formatters.Add(formatter);
|
options.Formatters.Add(formatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
var optionsAccessor = new Mock<IOptionsAccessor<WebApiCompatShimOptions>>();
|
var optionsAccessor = new Mock<IOptions<WebApiCompatShimOptions>>();
|
||||||
optionsAccessor.SetupGet(o => o.Options).Returns(options);
|
optionsAccessor.SetupGet(o => o.Options).Returns(options);
|
||||||
|
|
||||||
var services = new Mock<IServiceProvider>(MockBehavior.Strict);
|
var services = new Mock<IServiceProvider>(MockBehavior.Strict);
|
||||||
services
|
services
|
||||||
.Setup(s => s.GetService(typeof(IOptionsAccessor<WebApiCompatShimOptions>)))
|
.Setup(s => s.GetService(typeof(IOptions<WebApiCompatShimOptions>)))
|
||||||
.Returns(optionsAccessor.Object);
|
.Returns(optionsAccessor.Object);
|
||||||
|
|
||||||
if (contentNegotiator != null)
|
if (contentNegotiator != null)
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ namespace ActivatorWebSite
|
||||||
var configuration = app.GetTestConfiguration();
|
var configuration = app.GetTestConfiguration();
|
||||||
|
|
||||||
// Set up application services
|
// Set up application services
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
// Add MVC services to the services container
|
// Add MVC services to the services container
|
||||||
services.AddMvc(configuration);
|
services.AddMvc(configuration);
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ namespace AntiForgeryWebSite
|
||||||
public void Configure(IApplicationBuilder app)
|
public void Configure(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
var configuration = app.GetTestConfiguration();
|
var configuration = app.GetTestConfiguration();
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
services.AddMvc(configuration);
|
services.AddMvc(configuration);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,12 @@ namespace ApiExplorer
|
||||||
{
|
{
|
||||||
var configuration = app.GetTestConfiguration();
|
var configuration = app.GetTestConfiguration();
|
||||||
|
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
services.AddMvc(configuration);
|
services.AddMvc(configuration);
|
||||||
services.AddSingleton<ApiExplorerDataFilter>();
|
services.AddSingleton<ApiExplorerDataFilter>();
|
||||||
|
|
||||||
services.ConfigureOptions<MvcOptions>(options =>
|
services.Configure<MvcOptions>(options =>
|
||||||
{
|
{
|
||||||
options.Filters.AddService(typeof(ApiExplorerDataFilter));
|
options.Filters.AddService(typeof(ApiExplorerDataFilter));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace ApplicationModelWebSite
|
||||||
{
|
{
|
||||||
var configuration = app.GetTestConfiguration();
|
var configuration = app.GetTestConfiguration();
|
||||||
|
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
services.AddMvc(configuration);
|
services.AddMvc(configuration);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace AutofacWebSite
|
||||||
{
|
{
|
||||||
var configuration = app.GetTestConfiguration();
|
var configuration = app.GetTestConfiguration();
|
||||||
|
|
||||||
app.UsePerRequestServices(services => {
|
app.UseServices(services => {
|
||||||
services.AddMvc(configuration);
|
services.AddMvc(configuration);
|
||||||
services.AddTransient<HelloWorldBuilder>();
|
services.AddTransient<HelloWorldBuilder>();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace BasicWebSite
|
||||||
var configuration = app.GetTestConfiguration();
|
var configuration = app.GetTestConfiguration();
|
||||||
|
|
||||||
// Set up application services
|
// Set up application services
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
// Add MVC services to the services container
|
// Add MVC services to the services container
|
||||||
services.AddMvc(configuration);
|
services.AddMvc(configuration);
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@ namespace CompositeViewEngine
|
||||||
var configuration = app.GetTestConfiguration();
|
var configuration = app.GetTestConfiguration();
|
||||||
|
|
||||||
// Set up application services
|
// Set up application services
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
// Add a view engine as the first one in the list.
|
// Add a view engine as the first one in the list.
|
||||||
services.AddMvc(configuration)
|
services.AddMvc(configuration)
|
||||||
.ConfigureOptions<MvcOptions>(options =>
|
.Configure<MvcOptions>(options =>
|
||||||
{
|
{
|
||||||
options.ViewEngines.Insert(0, typeof(TestViewEngine));
|
options.ViewEngines.Insert(0, typeof(TestViewEngine));
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ namespace ConnegWebsite
|
||||||
var configuration = app.GetTestConfiguration();
|
var configuration = app.GetTestConfiguration();
|
||||||
|
|
||||||
// Set up application services
|
// Set up application services
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
// Add MVC services to the services container
|
// Add MVC services to the services container
|
||||||
services.AddMvc(configuration);
|
services.AddMvc(configuration);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace FilesWebSite
|
||||||
{
|
{
|
||||||
var configuration = app.GetTestConfiguration();
|
var configuration = app.GetTestConfiguration();
|
||||||
|
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
services.AddMvc(configuration);
|
services.AddMvc(configuration);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@ namespace FiltersWebSite
|
||||||
{
|
{
|
||||||
var configuration = app.GetTestConfiguration();
|
var configuration = app.GetTestConfiguration();
|
||||||
|
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
services.AddMvc(configuration);
|
services.AddMvc(configuration);
|
||||||
|
|
||||||
services.ConfigureOptions<MvcOptions>(options =>
|
services.Configure<MvcOptions>(options =>
|
||||||
{
|
{
|
||||||
options.Filters.Add(new GlobalExceptionFilter());
|
options.Filters.Add(new GlobalExceptionFilter());
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ namespace FormatterWebSite
|
||||||
var configuration = app.GetTestConfiguration();
|
var configuration = app.GetTestConfiguration();
|
||||||
|
|
||||||
// Set up application services
|
// Set up application services
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
// Add MVC services to the services container
|
// Add MVC services to the services container
|
||||||
services.AddMvc(configuration);
|
services.AddMvc(configuration);
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ namespace InlineConstraints
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up application services
|
// Set up application services
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
// Add MVC services to the services container
|
// Add MVC services to the services container
|
||||||
services.AddMvc(configuration);
|
services.AddMvc(configuration);
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@ namespace ModelBindingWebSite
|
||||||
var configuration = app.GetTestConfiguration();
|
var configuration = app.GetTestConfiguration();
|
||||||
|
|
||||||
// Set up application services
|
// Set up application services
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
// Add MVC services to the services container
|
// Add MVC services to the services container
|
||||||
services.AddMvc(configuration)
|
services.AddMvc(configuration)
|
||||||
.ConfigureOptions<MvcOptions>(m =>
|
.Configure<MvcOptions>(m =>
|
||||||
{
|
{
|
||||||
m.MaxModelValidationErrors = 8;
|
m.MaxModelValidationErrors = 8;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ namespace RazorInstrumentationWebSite
|
||||||
var configuration = app.GetTestConfiguration();
|
var configuration = app.GetTestConfiguration();
|
||||||
|
|
||||||
// Set up application services
|
// Set up application services
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
// Add MVC services to the services container
|
// Add MVC services to the services container
|
||||||
services.AddMvc(configuration);
|
services.AddMvc(configuration);
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,12 @@ namespace RazorWebSite
|
||||||
var configuration = app.GetTestConfiguration();
|
var configuration = app.GetTestConfiguration();
|
||||||
|
|
||||||
// Set up application services
|
// Set up application services
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
// Add MVC services to the services container
|
// Add MVC services to the services container
|
||||||
services.AddMvc(configuration);
|
services.AddMvc(configuration);
|
||||||
services.AddTransient<InjectedHelper>();
|
services.AddTransient<InjectedHelper>();
|
||||||
services.ConfigureOptions<RazorViewEngineOptions>(options =>
|
services.Configure<RazorViewEngineOptions>(options =>
|
||||||
{
|
{
|
||||||
var expander = new LanguageViewLocationExpander(
|
var expander = new LanguageViewLocationExpander(
|
||||||
context => context.HttpContext.Request.Query["language-expander-value"]);
|
context => context.HttpContext.Request.Query["language-expander-value"]);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace RoutingWebSite
|
||||||
{
|
{
|
||||||
var configuration = app.GetTestConfiguration();
|
var configuration = app.GetTestConfiguration();
|
||||||
|
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
services.AddMvc(configuration);
|
services.AddMvc(configuration);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace TagHelpersWebSite
|
||||||
{
|
{
|
||||||
var configuration = app.GetTestConfiguration();
|
var configuration = app.GetTestConfiguration();
|
||||||
|
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
services.AddMvc(configuration);
|
services.AddMvc(configuration);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@ namespace UrlHelperWebSite
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CustomUrlHelper : UrlHelper
|
public class CustomUrlHelper : UrlHelper
|
||||||
{
|
{
|
||||||
private readonly IOptionsAccessor<AppOptions> _appOptions;
|
private readonly IOptions<AppOptions> _appOptions;
|
||||||
private readonly HttpContext _httpContext;
|
private readonly HttpContext _httpContext;
|
||||||
|
|
||||||
public CustomUrlHelper(IContextAccessor<ActionContext> contextAccessor, IActionSelector actionSelector,
|
public CustomUrlHelper(IContextAccessor<ActionContext> contextAccessor, IActionSelector actionSelector,
|
||||||
IOptionsAccessor<AppOptions> appOptions)
|
IOptions<AppOptions> appOptions)
|
||||||
: base(contextAccessor, actionSelector)
|
: base(contextAccessor, actionSelector)
|
||||||
{
|
{
|
||||||
_appOptions = appOptions;
|
_appOptions = appOptions;
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,9 @@ namespace UrlHelperWebSite
|
||||||
var configuration = app.GetTestConfiguration();
|
var configuration = app.GetTestConfiguration();
|
||||||
|
|
||||||
// Set up application services
|
// Set up application services
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
services.ConfigureOptions<AppOptions>(optionsSetup =>
|
services.Configure<AppOptions>(optionsSetup =>
|
||||||
{
|
{
|
||||||
optionsSetup.ServeCDNContent = true;
|
optionsSetup.ServeCDNContent = true;
|
||||||
optionsSetup.CDNServerBaseUrl = "http://cdn.contoso.com";
|
optionsSetup.CDNServerBaseUrl = "http://cdn.contoso.com";
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@ namespace ValueProvidersSite
|
||||||
var configuration = app.GetTestConfiguration();
|
var configuration = app.GetTestConfiguration();
|
||||||
|
|
||||||
// Set up application services
|
// Set up application services
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
// Add MVC services to the services container
|
// Add MVC services to the services container
|
||||||
services.AddMvc(configuration)
|
services.AddMvc(configuration)
|
||||||
.ConfigureOptions<MvcOptions>(options =>
|
.Configure<MvcOptions>(options =>
|
||||||
{
|
{
|
||||||
options.ValueProviderFactories.Insert(1, new CustomValueProviderFactory());
|
options.ValueProviderFactories.Insert(1, new CustomValueProviderFactory());
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace VersioningWebSite
|
||||||
{
|
{
|
||||||
var configuration = app.GetTestConfiguration();
|
var configuration = app.GetTestConfiguration();
|
||||||
|
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
services.AddMvc(configuration);
|
services.AddMvc(configuration);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ namespace WebApiCompatShimWebSite
|
||||||
public class BasicApiController : ApiController
|
public class BasicApiController : ApiController
|
||||||
{
|
{
|
||||||
[Activate]
|
[Activate]
|
||||||
public IOptionsAccessor<WebApiCompatShimOptions> OptionsAccessor { get; set; }
|
public IOptions<WebApiCompatShimOptions> OptionsAccessor { get; set; }
|
||||||
|
|
||||||
// Verifies property activation
|
// Verifies property activation
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace WebApiCompatShimWebSite
|
||||||
{
|
{
|
||||||
var configuration = app.GetTestConfiguration();
|
var configuration = app.GetTestConfiguration();
|
||||||
|
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
services.AddMvc(configuration);
|
services.AddMvc(configuration);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,12 @@ namespace XmlSerializerWebSite
|
||||||
var configuration = app.GetTestConfiguration();
|
var configuration = app.GetTestConfiguration();
|
||||||
|
|
||||||
// Set up application services
|
// Set up application services
|
||||||
app.UsePerRequestServices(services =>
|
app.UseServices(services =>
|
||||||
{
|
{
|
||||||
// Add MVC services to the services container
|
// Add MVC services to the services container
|
||||||
services.AddMvc(configuration);
|
services.AddMvc(configuration);
|
||||||
|
|
||||||
services.ConfigureOptions<MvcOptions>(options =>
|
services.Configure<MvcOptions>(options =>
|
||||||
{
|
{
|
||||||
options.InputFormatters.Clear();
|
options.InputFormatters.Clear();
|
||||||
options.InputFormatters.Insert(0, new XmlSerializerInputFormatter());
|
options.InputFormatters.Insert(0, new XmlSerializerInputFormatter());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue