12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using System.Globalization;
- using System.Resources;
- using System.Threading;
- namespace System.Configuration.InstallUtilResources
- {
- internal sealed class Res
- {
- internal const string InstallUtilSignOnMessage = "InstallUtilSignOnMessage";
- private static Res loader;
- private ResourceManager resources;
- private static object s_InternalSyncObject;
- private static object InternalSyncObject
- {
- get
- {
- if (s_InternalSyncObject == null)
- {
- object value = new object();
- Interlocked.CompareExchange(ref s_InternalSyncObject, value, null);
- }
- return s_InternalSyncObject;
- }
- }
- private static CultureInfo Culture => null;
- public static ResourceManager Resources => GetLoader().resources;
- internal Res()
- {
- resources = new ResourceManager("InstallUtil", GetType().Assembly);
- }
- private static Res GetLoader()
- {
- if (loader == null)
- {
- lock (InternalSyncObject)
- {
- if (loader == null)
- {
- loader = new Res();
- }
- }
- }
- return loader;
- }
- public static string GetString(string name, params object[] args)
- {
- Res res = GetLoader();
- if (res == null)
- {
- return null;
- }
- string @string = res.resources.GetString(name, Culture);
- if (args != null && args.Length > 0)
- {
- for (int i = 0; i < args.Length; i++)
- {
- string text = args[i] as string;
- if (text != null && text.Length > 1024)
- {
- args[i] = text.Substring(0, 1021) + "...";
- }
- }
- return string.Format(CultureInfo.CurrentCulture, @string, args);
- }
- return @string;
- }
- public static string GetString(string name)
- {
- return GetLoader()?.resources.GetString(name, Culture);
- }
- public static object GetObject(string name)
- {
- return GetLoader()?.resources.GetObject(name, Culture);
- }
- }
- }
|