/[xmltv_parser]/trunk/libxmltv/Core/ResourceStringHelper.cs
ViewVC logotype

Annotation of /trunk/libxmltv/Core/ResourceStringHelper.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 93 - (hide annotations) (download)
Sun Mar 10 08:44:53 2013 UTC (7 years, 7 months ago) by william
File size: 1951 byte(s)

1 william 93 using System;
2     using System.Collections.Generic;
3     using System.Linq;
4     using System.Text;
5     using System.Globalization;
6     using System.Reflection;
7     using System.Diagnostics;
8    
9     namespace libxmltv.Core
10     {
11     internal static class ResourceStringHelper
12     {
13     internal static string GetResourceString(string key)
14     {
15     //throw new NotImplementedException("GetResourceString(string key) is not implemented");
16     return GetResourceFromDefault(key);
17     }
18     internal static string GetResourceString(string key, params object[] values)
19     { //throw new NotImplementedException("GetResourceString(string key, params object[] values) is not implemented");
20     string resourceFromDefault = GetResourceFromDefault(key);
21     return string.Format(CultureInfo.CurrentCulture, resourceFromDefault, values);
22     }
23     internal static string GetResourceFromDefault(string key)
24     {
25     //throw new NotImplementedException("GetResourceFromDefault(string key) is not implemented");
26     string res_string = string.Empty;
27     try
28     {
29     string MethodName = "GetResourceFromDefault";
30     var t = typeof(Environment);
31     var method = t.GetMethod(MethodName, BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.FlattenHierarchy);
32     if (method == null) { throw new Exception("Environment.GetResourceFromDefault(string key): could not bind to method."); }
33     res_string = method.Invoke(null, new object[] { key }).ToString();
34     }
35     catch (Exception ex)
36     {
37     Debug.WriteLine(ex.ToString());
38     throw new Exception("Environment.GetResourceFromDefault(string key): unable to retrieve default resource string.", ex);
39     }
40     return res_string;
41     }
42     }
43     }

  ViewVC Help
Powered by ViewVC 1.1.22