|
using System;
using System.Collections.Generic;
using System.Text;
namespace WpfLocalization
{
/// <summary>
/// Formats a list of objects to produce a string value.
/// </summary>
public class FormattedLocalizedValue : LocalizedValue
{
string _formatString;
object[] _args;
/// <summary>
/// Initializes a new instance of the <see cref="FormattedLocalizedValue"/> class.
/// </summary>
/// <param name="property">The property.</param>
/// <param name="formatString">The format string.</param>
/// <param name="args">The args.</param>
/// <exception cref="ArgumentNullException"><paramref name="property"/> is null.</exception>
/// <exception cref="ArgumentNullException"><paramref name="formatString"/> is null.</exception>
/// <exception cref="ArgumentNullException"><paramref name="args"/> is null.</exception>
public FormattedLocalizedValue(LocalizedProperty property, string formatString, params object[] args)
: base(property)
{
if (formatString == null)
{
throw new ArgumentNullException("formatString");
}
if (args == null)
{
throw new ArgumentNullException("args");
}
_formatString = formatString;
_args = args;
}
/// <summary>
/// Retrieves the localized value from resources or by other means.
/// </summary>
/// <returns>
/// The localized value.
/// </returns>
protected override object GetLocalizedValue()
{
var culture = Property.GetCulture();
return string.Format(culture, _formatString, _args);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.