Class StringFormatMessageFormatter

Namespace
RentADeveloper.ResXLocalization
Assembly
ResXLocalization.Core.dll

The default IMessageFormatter: returns a value without arguments unchanged, and formats a value with arguments with Format(IFormatProvider, string, params object[]) in the lookup's culture. Argument names are ignored; only positions count.

public sealed class StringFormatMessageFormatter : IMessageFormatter
Inheritance
StringFormatMessageFormatter
Implements
Inherited Members

Fields

Instance

The shared instance, and the default of MessageFormatter.

public static readonly StringFormatMessageFormatter Instance

Field Value

StringFormatMessageFormatter

Methods

Format(string, MessageArguments, CultureInfo)

Returns pattern unchanged when arguments is empty; otherwise formats it as a composite format string with the argument values in culture. Each value fills the placeholder of its Position: the argument at position 1 fills {1}, whatever its index in the enumeration.

public string Format(string pattern, MessageArguments arguments, CultureInfo culture)

Parameters

pattern string

The resolved resource value.

arguments MessageArguments

The arguments of the lookup; never null.

culture CultureInfo

The culture to format in.

Returns

string

The formatted string, or pattern when there are no arguments.

Exceptions

FormatException

pattern is not a valid composite format string for arguments. The localizer catches it and returns the failure text.