using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Globalization; using System.Reflection; using System.Diagnostics; namespace libxmltv.Core { internal static class ResourceStringHelper { internal static string GetResourceString(string key) { //throw new NotImplementedException("GetResourceString(string key) is not implemented"); return GetResourceFromDefault(key); } internal static string GetResourceString(string key, params object[] values) { //throw new NotImplementedException("GetResourceString(string key, params object[] values) is not implemented"); string resourceFromDefault = GetResourceFromDefault(key); return string.Format(CultureInfo.CurrentCulture, resourceFromDefault, values); } internal static string GetResourceFromDefault(string key) { //throw new NotImplementedException("GetResourceFromDefault(string key) is not implemented"); string res_string = string.Empty; try { string MethodName = "GetResourceFromDefault"; var t = typeof(Environment); var method = t.GetMethod(MethodName, BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.FlattenHierarchy); if (method == null) { throw new Exception("Environment.GetResourceFromDefault(string key): could not bind to method."); } res_string = method.Invoke(null, new object[] { key }).ToString(); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); throw new Exception("Environment.GetResourceFromDefault(string key): unable to retrieve default resource string.", ex); } return res_string; } } }