diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Internal/Error.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/Internal/Error.cs
index 8945888076..f9df587396 100644
--- a/src/Microsoft.AspNet.Mvc.ModelBinding/Internal/Error.cs
+++ b/src/Microsoft.AspNet.Mvc.ModelBinding/Internal/Error.cs
@@ -7,40 +7,18 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Internal
{
internal static ArgumentException ArgumentNull(string paramName)
{
- throw new ArgumentNullException(paramName);
- }
-
- internal static Exception InvalidOperation(string message, params object[] args)
- {
- throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, message, args));
- }
-
- internal static Exception InvalidOperation(Exception ex, string message, params object[] args)
- {
- throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, message, args), ex);
- }
-
- ///
- /// Creates an with the provided properties.
- ///
- /// A composite format string explaining the reason for the exception.
- /// An object array that contains zero or more objects to format.
- /// The logged .
- internal static ArgumentException Argument(string messageFormat, params object[] messageArgs)
- {
- return new ArgumentException(String.Format(CultureInfo.CurrentCulture, messageFormat, messageArgs));
+ return new ArgumentNullException(paramName);
}
///
/// Creates an with the provided properties.
///
/// The name of the parameter that caused the current exception.
- /// A composite format string explaining the reason for the exception.
- /// An object array that contains zero or more objects to format.
+ /// A composite message explaining the reason for the exception.
/// The logged .
- internal static ArgumentException Argument(string parameterName, string messageFormat, params object[] messageArgs)
+ internal static ArgumentException Argument(string parameterName, string message)
{
- return new ArgumentException(String.Format(CultureInfo.CurrentCulture, messageFormat, messageArgs), parameterName);
+ return new ArgumentException(message, parameterName);
}
///
@@ -50,7 +28,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Internal
/// The logged .
internal static ArgumentException ArgumentNullOrEmpty(string parameterName)
{
- return Error.Argument(parameterName, Resources.ArgumentNullOrEmpty, parameterName);
+ return Error.Argument(parameterName, Resources.FormatArgumentNullOrEmpty(parameterName));
}
}
}
diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Internal/ModelBindingHelper.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/Internal/ModelBindingHelper.cs
index 23d564f35e..5110a50088 100644
--- a/src/Microsoft.AspNet.Mvc.ModelBinding/Internal/ModelBindingHelper.cs
+++ b/src/Microsoft.AspNet.Mvc.ModelBinding/Internal/ModelBindingHelper.cs
@@ -72,17 +72,22 @@ namespace Microsoft.AspNet.Mvc.ModelBinding.Internal
if (bindingContext.ModelType != requiredType)
{
- throw Error.Argument("bindingContext", Resources.ModelBinderUtil_ModelTypeIsWrong, bindingContext.ModelType, requiredType);
+ var message = Resources.FormatModelBinderUtil_ModelTypeIsWrong(bindingContext.ModelType, requiredType);
+ throw Error.Argument("bindingContext", message);
}
if (!allowNullModel && bindingContext.Model == null)
{
- throw Error.Argument("bindingContext", Resources.ModelBinderUtil_ModelCannotBeNull, requiredType);
+ var message = Resources.FormatModelBinderUtil_ModelCannotBeNull(requiredType);
+ throw Error.Argument("bindingContext", message);
}
if (bindingContext.Model != null && !bindingContext.ModelType.GetTypeInfo().IsAssignableFrom(requiredType.GetTypeInfo()))
{
- throw Error.Argument("bindingContext", Resources.ModelBinderUtil_ModelInstanceIsWrong, bindingContext.Model.GetType(), requiredType);
+ var message = Resources.FormatModelBinderUtil_ModelInstanceIsWrong(
+ bindingContext.Model.GetType(),
+ requiredType);
+ throw Error.Argument("bindingContext", message);
}
}
}
diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Metadata/AssociatedMetadataProvider.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/Metadata/AssociatedMetadataProvider.cs
index abcc5c061a..005fcfe081 100644
--- a/src/Microsoft.AspNet.Mvc.ModelBinding/Metadata/AssociatedMetadataProvider.cs
+++ b/src/Microsoft.AspNet.Mvc.ModelBinding/Metadata/AssociatedMetadataProvider.cs
@@ -39,7 +39,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
PropertyInformation propertyInfo;
if (!typeInfo.Properties.TryGetValue(propertyName, out propertyInfo))
{
- throw Error.Argument("propertyName", Resources.Common_PropertyNotFound, containerType, propertyName);
+ throw Error.Argument("propertyName", Resources.FormatCommon_PropertyNotFound(containerType, propertyName));
}
return CreateMetadataFromPrototype(propertyInfo.Prototype, modelAccessor);
diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/ModelBindingContext.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/ModelBindingContext.cs
index 2c4b5517fc..8e4387c8fa 100644
--- a/src/Microsoft.AspNet.Mvc.ModelBinding/ModelBindingContext.cs
+++ b/src/Microsoft.AspNet.Mvc.ModelBinding/ModelBindingContext.cs
@@ -106,7 +106,7 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
{
if (ModelMetadata == null)
{
- throw Error.InvalidOperation(Resources.ModelBindingContext_ModelMetadataMustBeSet);
+ throw new InvalidOperationException(Resources.ModelBindingContext_ModelMetadataMustBeSet);
}
}
}
diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Properties/Resources.Designer.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/Properties/Resources.Designer.cs
new file mode 100644
index 0000000000..59eeff47d9
--- /dev/null
+++ b/src/Microsoft.AspNet.Mvc.ModelBinding/Properties/Resources.Designer.cs
@@ -0,0 +1,254 @@
+//
+namespace Microsoft.AspNet.Mvc.ModelBinding
+{
+ using System.Globalization;
+ using System.Reflection;
+ using System.Resources;
+
+ internal static class Resources
+ {
+ private static readonly ResourceManager _resourceManager
+ = new ResourceManager("Microsoft.AspNet.Mvc.ModelBinding.Resources", typeof(Resources).GetTypeInfo().Assembly);
+
+ ///
+ /// The argument '{0}' is null or empty.
+ ///
+ internal static string ArgumentNullOrEmpty
+ {
+ get { return GetString("ArgumentNullOrEmpty"); }
+ }
+
+ ///
+ /// The argument '{0}' is null or empty.
+ ///
+ internal static string FormatArgumentNullOrEmpty(object p0)
+ {
+ return string.Format(CultureInfo.CurrentCulture, GetString("ArgumentNullOrEmpty"), p0);
+ }
+
+ ///
+ /// The property {0}.{1} could not be found.
+ ///
+ internal static string Common_PropertyNotFound
+ {
+ get { return GetString("Common_PropertyNotFound"); }
+ }
+
+ ///
+ /// The property {0}.{1} could not be found.
+ ///
+ internal static string FormatCommon_PropertyNotFound(object p0, object p1)
+ {
+ return string.Format(CultureInfo.CurrentCulture, GetString("Common_PropertyNotFound"), p0, p1);
+ }
+
+ ///
+ /// The key is invalid JQuery syntax because it is missing a closing bracket.
+ ///
+ internal static string JQuerySyntaxMissingClosingBracket
+ {
+ get { return GetString("JQuerySyntaxMissingClosingBracket"); }
+ }
+
+ ///
+ /// The key is invalid JQuery syntax because it is missing a closing bracket.
+ ///
+ internal static string FormatJQuerySyntaxMissingClosingBracket()
+ {
+ return GetString("JQuerySyntaxMissingClosingBracket");
+ }
+
+ ///
+ /// The value '{0}' is not valid for {1}.
+ ///
+ internal static string ModelBinderConfig_ValueInvalid
+ {
+ get { return GetString("ModelBinderConfig_ValueInvalid"); }
+ }
+
+ ///
+ /// The value '{0}' is not valid for {1}.
+ ///
+ internal static string FormatModelBinderConfig_ValueInvalid(object p0, object p1)
+ {
+ return string.Format(CultureInfo.CurrentCulture, GetString("ModelBinderConfig_ValueInvalid"), p0, p1);
+ }
+
+ ///
+ /// A value is required.
+ ///
+ internal static string ModelBinderConfig_ValueRequired
+ {
+ get { return GetString("ModelBinderConfig_ValueRequired"); }
+ }
+
+ ///
+ /// A value is required.
+ ///
+ internal static string FormatModelBinderConfig_ValueRequired()
+ {
+ return GetString("ModelBinderConfig_ValueRequired");
+ }
+
+ ///
+ /// The binding context has a null Model, but this binder requires a non-null model of type '{0}'.
+ ///
+ internal static string ModelBinderUtil_ModelCannotBeNull
+ {
+ get { return GetString("ModelBinderUtil_ModelCannotBeNull"); }
+ }
+
+ ///
+ /// The binding context has a null Model, but this binder requires a non-null model of type '{0}'.
+ ///
+ internal static string FormatModelBinderUtil_ModelCannotBeNull(object p0)
+ {
+ return string.Format(CultureInfo.CurrentCulture, GetString("ModelBinderUtil_ModelCannotBeNull"), p0);
+ }
+
+ ///
+ /// The binding context has a Model of type '{0}', but this binder can only operate on models of type '{1}'.
+ ///
+ internal static string ModelBinderUtil_ModelInstanceIsWrong
+ {
+ get { return GetString("ModelBinderUtil_ModelInstanceIsWrong"); }
+ }
+
+ ///
+ /// The binding context has a Model of type '{0}', but this binder can only operate on models of type '{1}'.
+ ///
+ internal static string FormatModelBinderUtil_ModelInstanceIsWrong(object p0, object p1)
+ {
+ return string.Format(CultureInfo.CurrentCulture, GetString("ModelBinderUtil_ModelInstanceIsWrong"), p0, p1);
+ }
+
+ ///
+ /// The binding context cannot have a null ModelMetadata.
+ ///
+ internal static string ModelBinderUtil_ModelMetadataCannotBeNull
+ {
+ get { return GetString("ModelBinderUtil_ModelMetadataCannotBeNull"); }
+ }
+
+ ///
+ /// The binding context cannot have a null ModelMetadata.
+ ///
+ internal static string FormatModelBinderUtil_ModelMetadataCannotBeNull()
+ {
+ return GetString("ModelBinderUtil_ModelMetadataCannotBeNull");
+ }
+
+ ///
+ /// The binding context has a ModelType of '{0}', but this binder can only operate on models of type '{1}'.
+ ///
+ internal static string ModelBinderUtil_ModelTypeIsWrong
+ {
+ get { return GetString("ModelBinderUtil_ModelTypeIsWrong"); }
+ }
+
+ ///
+ /// The binding context has a ModelType of '{0}', but this binder can only operate on models of type '{1}'.
+ ///
+ internal static string FormatModelBinderUtil_ModelTypeIsWrong(object p0, object p1)
+ {
+ return string.Format(CultureInfo.CurrentCulture, GetString("ModelBinderUtil_ModelTypeIsWrong"), p0, p1);
+ }
+
+ ///
+ /// The ModelMetadata property must be set before accessing this property.
+ ///
+ internal static string ModelBindingContext_ModelMetadataMustBeSet
+ {
+ get { return GetString("ModelBindingContext_ModelMetadataMustBeSet"); }
+ }
+
+ ///
+ /// The ModelMetadata property must be set before accessing this property.
+ ///
+ internal static string FormatModelBindingContext_ModelMetadataMustBeSet()
+ {
+ return GetString("ModelBindingContext_ModelMetadataMustBeSet");
+ }
+
+ ///
+ /// The parameter conversion from type '{0}' to type '{1}' failed. See the inner exception for more information.
+ ///
+ internal static string ValueProviderResult_ConversionThrew
+ {
+ get { return GetString("ValueProviderResult_ConversionThrew"); }
+ }
+
+ ///
+ /// The parameter conversion from type '{0}' to type '{1}' failed. See the inner exception for more information.
+ ///
+ internal static string FormatValueProviderResult_ConversionThrew(object p0, object p1)
+ {
+ return string.Format(CultureInfo.CurrentCulture, GetString("ValueProviderResult_ConversionThrew"), p0, p1);
+ }
+
+ ///
+ /// The parameter conversion from type '{0}' to type '{1}' failed because no type converter can convert between these types.
+ ///
+ internal static string ValueProviderResult_NoConverterExists
+ {
+ get { return GetString("ValueProviderResult_NoConverterExists"); }
+ }
+
+ ///
+ /// The parameter conversion from type '{0}' to type '{1}' failed because no type converter can convert between these types.
+ ///
+ internal static string FormatValueProviderResult_NoConverterExists(object p0, object p1)
+ {
+ return string.Format(CultureInfo.CurrentCulture, GetString("ValueProviderResult_NoConverterExists"), p0, p1);
+ }
+
+ ///
+ /// The model item passed is null, but this ViewData instance requires a non-null model item of type '{0}'.
+ ///
+ internal static string ViewDataDictionary_ModelCannotBeNull
+ {
+ get { return GetString("ViewDataDictionary_ModelCannotBeNull"); }
+ }
+
+ ///
+ /// The model item passed is null, but this ViewData instance requires a non-null model item of type '{0}'.
+ ///
+ internal static string FormatViewDataDictionary_ModelCannotBeNull(object p0)
+ {
+ return string.Format(CultureInfo.CurrentCulture, GetString("ViewDataDictionary_ModelCannotBeNull"), p0);
+ }
+
+ ///
+ /// The model item passed into the ViewData is of type '{0}', but this ViewData instance requires a model item of type '{1}'.
+ ///
+ internal static string ViewData_WrongTModelType
+ {
+ get { return GetString("ViewData_WrongTModelType"); }
+ }
+
+ ///
+ /// The model item passed into the ViewData is of type '{0}', but this ViewData instance requires a model item of type '{1}'.
+ ///
+ internal static string FormatViewData_WrongTModelType(object p0, object p1)
+ {
+ return string.Format(CultureInfo.CurrentCulture, GetString("ViewData_WrongTModelType"), p0, p1);
+ }
+
+ private static string GetString(string name, params string[] formatterNames)
+ {
+ var value = _resourceManager.GetString(name);
+
+ System.Diagnostics.Debug.Assert(value != null);
+
+ if (formatterNames != null)
+ {
+ for (var i = 0; i < formatterNames.Length; i++)
+ {
+ value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}");
+ }
+ }
+
+ return value;
+ }
+ }
+}
diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Resources.Designer.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/Resources.Designer.cs
deleted file mode 100644
index 8a79f8c152..0000000000
--- a/src/Microsoft.AspNet.Mvc.ModelBinding/Resources.Designer.cs
+++ /dev/null
@@ -1,189 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.34003
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace Microsoft.AspNet.Mvc.ModelBinding {
- using System;
-
-
- ///
- /// A strongly-typed resource class, for looking up localized strings, etc.
- ///
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources() {
- }
-
- ///
- /// Returns the cached ResourceManager instance used by this class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.AspNet.Mvc.ModelBinding.Resources", System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(Resources)).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
-
- ///
- /// Looks up a localized string similar to The argument '{0}' is null or empty..
- ///
- internal static string ArgumentNullOrEmpty {
- get {
- return ResourceManager.GetString("ArgumentNullOrEmpty", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to The property {0}.{1} could not be found..
- ///
- internal static string Common_PropertyNotFound {
- get {
- return ResourceManager.GetString("Common_PropertyNotFound", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to The key is invalid JQuery syntax because it is missing a closing bracket..
- ///
- internal static string JQuerySyntaxMissingClosingBracket {
- get {
- return ResourceManager.GetString("JQuerySyntaxMissingClosingBracket", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to The value '{0}' is not valid for {1}..
- ///
- internal static string ModelBinderConfig_ValueInvalid {
- get {
- return ResourceManager.GetString("ModelBinderConfig_ValueInvalid", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to A value is required..
- ///
- internal static string ModelBinderConfig_ValueRequired {
- get {
- return ResourceManager.GetString("ModelBinderConfig_ValueRequired", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to The binding context has a null Model, but this binder requires a non-null model of type '{0}'..
- ///
- internal static string ModelBinderUtil_ModelCannotBeNull {
- get {
- return ResourceManager.GetString("ModelBinderUtil_ModelCannotBeNull", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to The binding context has a Model of type '{0}', but this binder can only operate on models of type '{1}'..
- ///
- internal static string ModelBinderUtil_ModelInstanceIsWrong {
- get {
- return ResourceManager.GetString("ModelBinderUtil_ModelInstanceIsWrong", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to The binding context cannot have a null ModelMetadata..
- ///
- internal static string ModelBinderUtil_ModelMetadataCannotBeNull {
- get {
- return ResourceManager.GetString("ModelBinderUtil_ModelMetadataCannotBeNull", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to The binding context has a ModelType of '{0}', but this binder can only operate on models of type '{1}'..
- ///
- internal static string ModelBinderUtil_ModelTypeIsWrong {
- get {
- return ResourceManager.GetString("ModelBinderUtil_ModelTypeIsWrong", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to The ModelMetadata property must be set before accessing this property..
- ///
- internal static string ModelBindingContext_ModelMetadataMustBeSet {
- get {
- return ResourceManager.GetString("ModelBindingContext_ModelMetadataMustBeSet", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to The parameter conversion from type '{0}' to type '{1}' failed. See the inner exception for more information..
- ///
- internal static string ValueProviderResult_ConversionThrew {
- get {
- return ResourceManager.GetString("ValueProviderResult_ConversionThrew", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to The parameter conversion from type '{0}' to type '{1}' failed because no type converter can convert between these types..
- ///
- internal static string ValueProviderResult_NoConverterExists {
- get {
- return ResourceManager.GetString("ValueProviderResult_NoConverterExists", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to The model item passed into the ViewData is of type '{0}', but this ViewData instance requires a model item of type '{1}'..
- ///
- internal static string ViewData_WrongTModelType {
- get {
- return ResourceManager.GetString("ViewData_WrongTModelType", resourceCulture);
- }
- }
-
- ///
- /// Looks up a localized string similar to The model item passed is null, but this ViewData instance requires a non-null model item of type '{0}'..
- ///
- internal static string ViewDataDictionary_ModelCannotBeNull {
- get {
- return ResourceManager.GetString("ViewDataDictionary_ModelCannotBeNull", resourceCulture);
- }
- }
- }
-}
diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/ValueProviders/ValueProviderResult.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/ValueProviders/ValueProviderResult.cs
index 57d75ac5c5..664bb47d91 100644
--- a/src/Microsoft.AspNet.Mvc.ModelBinding/ValueProviders/ValueProviderResult.cs
+++ b/src/Microsoft.AspNet.Mvc.ModelBinding/ValueProviders/ValueProviderResult.cs
@@ -96,7 +96,8 @@ namespace Microsoft.AspNet.Mvc.ModelBinding
{
return Convert.ToString(value);
}
- throw Error.InvalidOperation(Resources.ValueProviderResult_NoConverterExists, value.GetType(), destinationType);
+ string message = Resources.FormatValueProviderResult_NoConverterExists(value.GetType(), destinationType);
+ throw new InvalidOperationException(message);
// TODO: Revive once we get TypeConverters
//TypeConverter converter = TypeDescriptor.GetConverter(destinationType);
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorCodeParser.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorCodeParser.cs
index 959c4e0d22..04abf3bb4e 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorCodeParser.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorCodeParser.cs
@@ -36,7 +36,8 @@ namespace Microsoft.AspNet.Mvc.Razor
{
if (_modelStatementFound && _endInheritsLocation.HasValue)
{
- Context.OnError(_endInheritsLocation.Value, Resources.MvcRazorCodeParser_CannotHaveModelAndInheritsKeyword(ModelKeyword));
+ Context.OnError(_endInheritsLocation.Value,
+ Resources.FormatMvcRazorCodeParser_CannotHaveModelAndInheritsKeyword(ModelKeyword));
}
}
@@ -48,12 +49,13 @@ namespace Microsoft.AspNet.Mvc.Razor
SourceLocation endModelLocation = CurrentLocation;
- BaseTypeDirective(Resources.MvcRazorCodeParser_ModelKeywordMustBeFollowedByTypeName(ModelKeyword),
+ BaseTypeDirective(Resources.FormatMvcRazorCodeParser_ModelKeywordMustBeFollowedByTypeName(ModelKeyword),
CreateModelCodeGenerator);
if (_modelStatementFound)
{
- Context.OnError(endModelLocation, Resources.MvcRazorCodeParser_OnlyOneModelStatementIsAllowed(ModelKeyword));
+ Context.OnError(endModelLocation,
+ Resources.FormatMvcRazorCodeParser_OnlyOneModelStatementIsAllowed(ModelKeyword));
}
_modelStatementFound = true;
diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/Properties/Resources.Designer.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/Properties/Resources.Designer.cs
index 0f6988b433..97d038e5a3 100644
--- a/src/Microsoft.AspNet.Mvc.Razor.Host/Properties/Resources.Designer.cs
+++ b/src/Microsoft.AspNet.Mvc.Razor.Host/Properties/Resources.Designer.cs
@@ -1,6 +1,4 @@
-
//
-
namespace Microsoft.AspNet.Mvc.Razor.Host
{
using System.Globalization;
@@ -15,7 +13,15 @@ namespace Microsoft.AspNet.Mvc.Razor.Host
///
/// The 'inherits' keyword is not allowed when a '{0}' keyword is used.
///
- internal static string MvcRazorCodeParser_CannotHaveModelAndInheritsKeyword(object p0)
+ internal static string MvcRazorCodeParser_CannotHaveModelAndInheritsKeyword
+ {
+ get { return GetString("MvcRazorCodeParser_CannotHaveModelAndInheritsKeyword"); }
+ }
+
+ ///
+ /// The 'inherits' keyword is not allowed when a '{0}' keyword is used.
+ ///
+ internal static string FormatMvcRazorCodeParser_CannotHaveModelAndInheritsKeyword(object p0)
{
return string.Format(CultureInfo.CurrentCulture, GetString("MvcRazorCodeParser_CannotHaveModelAndInheritsKeyword"), p0);
}
@@ -23,7 +29,15 @@ namespace Microsoft.AspNet.Mvc.Razor.Host
///
/// The '{0}' keyword must be followed by a type name on the same line.
///
- internal static string MvcRazorCodeParser_ModelKeywordMustBeFollowedByTypeName(object p0)
+ internal static string MvcRazorCodeParser_ModelKeywordMustBeFollowedByTypeName
+ {
+ get { return GetString("MvcRazorCodeParser_ModelKeywordMustBeFollowedByTypeName"); }
+ }
+
+ ///
+ /// The '{0}' keyword must be followed by a type name on the same line.
+ ///
+ internal static string FormatMvcRazorCodeParser_ModelKeywordMustBeFollowedByTypeName(object p0)
{
return string.Format(CultureInfo.CurrentCulture, GetString("MvcRazorCodeParser_ModelKeywordMustBeFollowedByTypeName"), p0);
}
@@ -31,15 +45,33 @@ namespace Microsoft.AspNet.Mvc.Razor.Host
///
/// Only one '{0}' statement is allowed in a file.
///
- internal static string MvcRazorCodeParser_OnlyOneModelStatementIsAllowed(object p0)
+ internal static string MvcRazorCodeParser_OnlyOneModelStatementIsAllowed
+ {
+ get { return GetString("MvcRazorCodeParser_OnlyOneModelStatementIsAllowed"); }
+ }
+
+ ///
+ /// Only one '{0}' statement is allowed in a file.
+ ///
+ internal static string FormatMvcRazorCodeParser_OnlyOneModelStatementIsAllowed(object p0)
{
return string.Format(CultureInfo.CurrentCulture, GetString("MvcRazorCodeParser_OnlyOneModelStatementIsAllowed"), p0);
}
- private static string GetString(string name)
+ private static string GetString(string name, params string[] formatterNames)
{
- string value = _resourceManager.GetString(name);
+ var value = _resourceManager.GetString(name);
+
System.Diagnostics.Debug.Assert(value != null);
+
+ if (formatterNames != null)
+ {
+ for (var i = 0; i < formatterNames.Length; i++)
+ {
+ value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}");
+ }
+ }
+
return value;
}
}
diff --git a/src/Microsoft.AspNet.Mvc.Razor/Properties/Resources.Designer.cs b/src/Microsoft.AspNet.Mvc.Razor/Properties/Resources.Designer.cs
new file mode 100644
index 0000000000..ff0f6928c7
--- /dev/null
+++ b/src/Microsoft.AspNet.Mvc.Razor/Properties/Resources.Designer.cs
@@ -0,0 +1,46 @@
+//
+namespace Microsoft.AspNet.Mvc.Razor
+{
+ using System.Globalization;
+ using System.Reflection;
+ using System.Resources;
+
+ internal static class Resources
+ {
+ private static readonly ResourceManager _resourceManager
+ = new ResourceManager("Microsoft.AspNet.Mvc.Razor.Resources", typeof(Resources).GetTypeInfo().Assembly);
+
+ ///
+ /// Value cannot be null or empty.
+ ///
+ internal static string ArgumentCannotBeNullOrEmpty
+ {
+ get { return GetString("ArgumentCannotBeNullOrEmpty"); }
+ }
+
+ ///
+ /// Value cannot be null or empty.
+ ///
+ internal static string FormatArgumentCannotBeNullOrEmpty()
+ {
+ return GetString("ArgumentCannotBeNullOrEmpty");
+ }
+
+ private static string GetString(string name, params string[] formatterNames)
+ {
+ var value = _resourceManager.GetString(name);
+
+ System.Diagnostics.Debug.Assert(value != null);
+
+ if (formatterNames != null)
+ {
+ for (var i = 0; i < formatterNames.Length; i++)
+ {
+ value = value.Replace("{" + formatterNames[i] + "}", "{" + i + "}");
+ }
+ }
+
+ return value;
+ }
+ }
+}
diff --git a/src/Microsoft.AspNet.Mvc.Razor/Resources.Designer.cs b/src/Microsoft.AspNet.Mvc.Razor/Resources.Designer.cs
deleted file mode 100644
index 9fde1c7a34..0000000000
--- a/src/Microsoft.AspNet.Mvc.Razor/Resources.Designer.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.34003
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace Microsoft.AspNet.Mvc.Razor
-{
- using System;
-
-
- ///
- /// A strongly-typed resource class, for looking up localized strings, etc.
- ///
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources
- {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources()
- {
- }
-
- ///
- /// Returns the cached ResourceManager instance used by this class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager
- {
- get
- {
- if (object.ReferenceEquals(resourceMan, null))
- {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.AspNet.Mvc.Razor.Resources", System.Reflection.IntrospectionExtensions.GetTypeInfo(typeof(Resources)).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture
- {
- get
- {
- return resourceCulture;
- }
- set
- {
- resourceCulture = value;
- }
- }
-
- ///
- /// Looks up a localized string similar to Value cannot be null or empty..
- ///
- internal static string ArgumentCannotBeNullOrEmpty
- {
- get
- {
- return ResourceManager.GetString("ArgumentCannotBeNullOrEmpty", resourceCulture);
- }
- }
- }
-}