Reacting to new middleware options pattern
This commit is contained in:
parent
2eb6cd655b
commit
c8a59d7f3e
|
|
@ -1,6 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// 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.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using InlineConstraintSample.Web.Constraints;
|
using InlineConstraintSample.Web.Constraints;
|
||||||
using Microsoft.AspNet.Builder;
|
using Microsoft.AspNet.Builder;
|
||||||
using Microsoft.AspNet.Hosting;
|
using Microsoft.AspNet.Hosting;
|
||||||
|
|
@ -25,11 +26,11 @@ namespace InlineConstraintSample.Web
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app)
|
public void Configure(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
app.UseRequestLocalization(localizationOptions =>
|
app.UseRequestLocalization(new RequestLocalizationOptions
|
||||||
{
|
{
|
||||||
// Ignore ambient and client locale. Use same values as ReplaceCultureAttribute / CultureReplacerMiddleware.
|
// Ignore ambient and client locale. Use same values as ReplaceCultureAttribute / CultureReplacerMiddleware.
|
||||||
localizationOptions.DefaultRequestCulture = new RequestCulture("en-GB", "en-US");
|
DefaultRequestCulture = new RequestCulture("en-GB", "en-US"),
|
||||||
localizationOptions.RequestCultureProviders.Clear();
|
RequestCultureProviders = new List<IRequestCultureProvider>()
|
||||||
});
|
});
|
||||||
|
|
||||||
app.UseMvc();
|
app.UseMvc();
|
||||||
|
|
|
||||||
|
|
@ -22,19 +22,19 @@ namespace LocalizationSample.Web
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app)
|
public void Configure(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
app.UseRequestLocalization(options =>
|
app.UseRequestLocalization(new RequestLocalizationOptions
|
||||||
{
|
{
|
||||||
options.DefaultRequestCulture = new RequestCulture("en-US");
|
DefaultRequestCulture = new RequestCulture("en-US"),
|
||||||
options.SupportedCultures = new List<CultureInfo>
|
SupportedCultures = new List<CultureInfo>
|
||||||
{
|
{
|
||||||
new CultureInfo("fr"),
|
new CultureInfo("fr"),
|
||||||
new CultureInfo("en-GB"),
|
new CultureInfo("en-GB"),
|
||||||
};
|
},
|
||||||
options.SupportedUICultures = new List<CultureInfo>
|
SupportedUICultures = new List<CultureInfo>
|
||||||
{
|
{
|
||||||
new CultureInfo("fr"),
|
new CultureInfo("fr"),
|
||||||
new CultureInfo("en-GB"),
|
new CultureInfo("en-GB"),
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.UseMvcWithDefaultRoute();
|
app.UseMvcWithDefaultRoute();
|
||||||
|
|
|
||||||
|
|
@ -301,6 +301,7 @@ namespace Microsoft.AspNet.Mvc.Filters
|
||||||
var serviceCollection = new ServiceCollection();
|
var serviceCollection = new ServiceCollection();
|
||||||
if (registerServices != null)
|
if (registerServices != null)
|
||||||
{
|
{
|
||||||
|
serviceCollection.AddOptions();
|
||||||
serviceCollection.AddLogging();
|
serviceCollection.AddLogging();
|
||||||
registerServices(serviceCollection);
|
registerServices(serviceCollection);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,21 +43,21 @@ namespace RazorWebSite
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app)
|
public void Configure(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
app.UseRequestLocalization(options =>
|
app.UseRequestLocalization(new RequestLocalizationOptions
|
||||||
{
|
{
|
||||||
options.DefaultRequestCulture = new RequestCulture("en-GB", "en-US");
|
DefaultRequestCulture = new RequestCulture("en-GB", "en-US"),
|
||||||
options.SupportedCultures = new List<CultureInfo>
|
SupportedCultures = new List<CultureInfo>
|
||||||
{
|
{
|
||||||
new CultureInfo("fr"),
|
new CultureInfo("fr"),
|
||||||
new CultureInfo("en-GB"),
|
new CultureInfo("en-GB"),
|
||||||
new CultureInfo("en-US"),
|
new CultureInfo("en-US"),
|
||||||
};
|
},
|
||||||
options.SupportedUICultures = new List<CultureInfo>
|
SupportedUICultures = new List<CultureInfo>
|
||||||
{
|
{
|
||||||
new CultureInfo("fr"),
|
new CultureInfo("fr"),
|
||||||
new CultureInfo("en-GB"),
|
new CultureInfo("en-GB"),
|
||||||
new CultureInfo("en-US"),
|
new CultureInfo("en-US"),
|
||||||
};
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.UseMvcWithDefaultRoute();
|
app.UseMvcWithDefaultRoute();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue