fixing 2704 -- Rename LanguageViewLocationExpanderOption to LanguageViewLocationExpanderFormat

This commit is contained in:
Mugdha Kulkarni 2015-07-08 14:24:29 -07:00
parent 2d62553122
commit 8cb2aae4f5
6 changed files with 20 additions and 20 deletions

View File

@ -46,7 +46,7 @@ namespace MvcSample.Web
options.Filters.Add(new FormatFilterAttribute()); options.Filters.Add(new FormatFilterAttribute());
}); });
services.AddMvcLocalization(LanguageViewLocationExpanderOption.SubFolder); services.AddMvcLocalization(LanguageViewLocationExpanderFormat.SubFolder);
#if DNX451 #if DNX451
// Fully-qualify configuration path to avoid issues in functional tests. Just "config.json" would be fine // Fully-qualify configuration path to avoid issues in functional tests. Just "config.json" would be fine

View File

@ -25,23 +25,23 @@ namespace Microsoft.AspNet.Mvc.Razor
public class LanguageViewLocationExpander : IViewLocationExpander public class LanguageViewLocationExpander : IViewLocationExpander
{ {
private const string ValueKey = "language"; private const string ValueKey = "language";
private LanguageViewLocationExpanderOption _option; private LanguageViewLocationExpanderFormat _format;
/// <summary> /// <summary>
/// Instantiates a new <see cref="LanguageViewLocationExpander"/> instance. /// Instantiates a new <see cref="LanguageViewLocationExpander"/> instance.
/// </summary> /// </summary>
public LanguageViewLocationExpander() public LanguageViewLocationExpander()
: this(LanguageViewLocationExpanderOption.Suffix) : this(LanguageViewLocationExpanderFormat.Suffix)
{ {
} }
/// <summary> /// <summary>
/// Instantiates a new <see cref="DefaultTagHelperActivator"/> instance. /// Instantiates a new <see cref="DefaultTagHelperActivator"/> instance.
/// </summary> /// </summary>
/// <param name="option">The <see cref="LanguageViewLocationExpanderOption"/>.</param> /// <param name="format">The <see cref="LanguageViewLocationExpanderFormat"/>.</param>
public LanguageViewLocationExpander(LanguageViewLocationExpanderOption option) public LanguageViewLocationExpander(LanguageViewLocationExpanderFormat format)
{ {
_option = option; _format = format;
} }
/// <inheritdoc /> /// <inheritdoc />
@ -89,7 +89,7 @@ namespace Microsoft.AspNet.Mvc.Razor
while (temporaryCultureInfo != temporaryCultureInfo.Parent) while (temporaryCultureInfo != temporaryCultureInfo.Parent)
{ {
if (_option == LanguageViewLocationExpanderOption.SubFolder) if (_format == LanguageViewLocationExpanderFormat.SubFolder)
{ {
yield return location.Replace("{0}", temporaryCultureInfo.Name + "/{0}"); yield return location.Replace("{0}", temporaryCultureInfo.Name + "/{0}");
} }

View File

@ -6,10 +6,10 @@ namespace Microsoft.AspNet.Mvc.Razor
/// <summary> /// <summary>
/// Specifies the localized view format for <see cref="LanguageViewLocationExpander"/>. /// Specifies the localized view format for <see cref="LanguageViewLocationExpander"/>.
/// </summary> /// </summary>
public enum LanguageViewLocationExpanderOption public enum LanguageViewLocationExpanderFormat
{ {
/// <summary> /// <summary>
/// Locale is a subfolder under which the view exisits. /// Locale is a subfolder under which the view exists.
/// </summary> /// </summary>
/// <example> /// <example>
/// Home/Views/en-US/Index.chtml /// Home/Views/en-US/Index.chtml

View File

@ -108,22 +108,22 @@ namespace Microsoft.Framework.DependencyInjection
/// <returns>The <see cref="IServiceCollection"/>.</returns> /// <returns>The <see cref="IServiceCollection"/>.</returns>
public static IServiceCollection AddMvcLocalization([NotNull] this IServiceCollection services) public static IServiceCollection AddMvcLocalization([NotNull] this IServiceCollection services)
{ {
return AddMvcLocalization(services, LanguageViewLocationExpanderOption.Suffix); return AddMvcLocalization(services, LanguageViewLocationExpanderFormat.Suffix);
} }
/// <summary> /// <summary>
/// Adds Mvc localization to the application. /// Adds Mvc localization to the application.
/// </summary> /// </summary>
/// <param name="services">The <see cref="IServiceCollection"/>.</param> /// <param name="services">The <see cref="IServiceCollection"/>.</param>
/// <param name="option">The view format for localized views.</param> /// <param name="format">The view format for localized views.</param>
/// <returns>The <see cref="IServiceCollection"/>.</returns> /// <returns>The <see cref="IServiceCollection"/>.</returns>
public static IServiceCollection AddMvcLocalization( public static IServiceCollection AddMvcLocalization(
[NotNull] this IServiceCollection services, [NotNull] this IServiceCollection services,
LanguageViewLocationExpanderOption option) LanguageViewLocationExpanderFormat format)
{ {
services.ConfigureRazorViewEngine(options => services.ConfigureRazorViewEngine(options =>
{ {
options.ViewLocationExpanders.Add(new LanguageViewLocationExpander(option)); options.ViewLocationExpanders.Add(new LanguageViewLocationExpander(format));
}); });
return services; return services;

View File

@ -14,7 +14,7 @@ namespace Microsoft.AspNet.Mvc.Razor
{ {
yield return new object[] yield return new object[]
{ {
LanguageViewLocationExpanderOption.Suffix, LanguageViewLocationExpanderFormat.Suffix,
new[] new[]
{ {
"/Views/{1}/{0}.cshtml", "/Views/{1}/{0}.cshtml",
@ -33,7 +33,7 @@ namespace Microsoft.AspNet.Mvc.Razor
yield return new object[] yield return new object[]
{ {
LanguageViewLocationExpanderOption.SubFolder, LanguageViewLocationExpanderFormat.SubFolder,
new[] new[]
{ {
"/Views/{1}/{0}.cshtml", "/Views/{1}/{0}.cshtml",
@ -52,7 +52,7 @@ namespace Microsoft.AspNet.Mvc.Razor
yield return new object[] yield return new object[]
{ {
LanguageViewLocationExpanderOption.Suffix, LanguageViewLocationExpanderFormat.Suffix,
new[] new[]
{ {
"/Areas/{2}/Views/{1}/{0}.cshtml", "/Areas/{2}/Views/{1}/{0}.cshtml",
@ -75,7 +75,7 @@ namespace Microsoft.AspNet.Mvc.Razor
yield return new object[] yield return new object[]
{ {
LanguageViewLocationExpanderOption.SubFolder, LanguageViewLocationExpanderFormat.SubFolder,
new[] new[]
{ {
"/Areas/{2}/Views/{1}/{0}.cshtml", "/Areas/{2}/Views/{1}/{0}.cshtml",
@ -126,13 +126,13 @@ namespace Microsoft.AspNet.Mvc.Razor
[Theory] [Theory]
[MemberData(nameof(ViewLocationExpanderTestDataWithExpectedValues))] [MemberData(nameof(ViewLocationExpanderTestDataWithExpectedValues))]
public void ExpandViewLocations_SpecificLocale( public void ExpandViewLocations_SpecificLocale(
LanguageViewLocationExpanderOption option, LanguageViewLocationExpanderFormat format,
IEnumerable<string> viewLocations, IEnumerable<string> viewLocations,
IEnumerable<string> expectedViewLocations) IEnumerable<string> expectedViewLocations)
{ {
// Arrange // Arrange
var viewLocationExpanderContext = new ViewLocationExpanderContext(new ActionContext(),"testView", false); var viewLocationExpanderContext = new ViewLocationExpanderContext(new ActionContext(),"testView", false);
var languageViewLocationExpander = new LanguageViewLocationExpander(option); var languageViewLocationExpander = new LanguageViewLocationExpander(format);
viewLocationExpanderContext.Values = new Dictionary<string, string>(); viewLocationExpanderContext.Values = new Dictionary<string, string>();
viewLocationExpanderContext.Values["language"] = "en-GB"; viewLocationExpanderContext.Values["language"] = "en-GB";

View File

@ -32,7 +32,7 @@ namespace RazorWebSite
options.HtmlHelperOptions.ValidationMessageElement = "validationMessageElement"; options.HtmlHelperOptions.ValidationMessageElement = "validationMessageElement";
options.HtmlHelperOptions.ValidationSummaryMessageElement = "validationSummaryElement"; options.HtmlHelperOptions.ValidationSummaryMessageElement = "validationSummaryElement";
}); });
services.AddMvcLocalization(LanguageViewLocationExpanderOption.SubFolder); services.AddMvcLocalization(LanguageViewLocationExpanderFormat.SubFolder);
} }
public void Configure(IApplicationBuilder app) public void Configure(IApplicationBuilder app)