namespace GDNXFD.Alert.Config.Resources.Strings
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Resources;
using System.Reflection;
///
/// String provider acts as a resolver to allow data binding to resx files.
///
public class StringProvider
{
private static ObjectDataProvider provider;
///
/// Default constructor.
///
public StringProvider()
{
}
///
/// Object data provider from app.xaml
///
public static ObjectDataProvider Provider
{
get
{
if (provider == null)
provider = (ObjectDataProvider)App.Current.FindResource("Resources");
return provider;
}
}
///
/// Returns an instance of the resx file.
///
///
public StringResources GetResourceInstance()
{
return new StringResources();
}
///
/// Apply change to current culture and refresh the string provider.
///
///
public static void ChangeCulture(CultureInfo culture)
{
Properties.Resources.Culture = culture;
Provider.Refresh();
}
///
/// Get a property string from it name.
///
///
///
public static string GetString(string propertyName)
{
if (string.IsNullOrWhiteSpace(propertyName))
return string.Empty;
try
{
ResourceManager man = new ResourceManager("GDNXFD.Alert.Config.Resources.Strings.StringResources", Assembly.GetExecutingAssembly());
return man.GetString(propertyName);
}
catch
{
return string.Empty;
}
}
}
}