Beispiel #1
0
        internal static void LoadResourceData()
        {
            try
            {
                string filepath = System.Environment.ExpandEnvironmentVariables("%Windir%") + "\\System32\\Winrm\\" +
#if CORECLR
                                  "0409" /* TODO: don't assume it is always English on CSS? */
#else
                                  string.Concat("0", string.Format(CultureInfo.CurrentCulture, "{0:x2}", checked ((uint)CultureInfo.CurrentUICulture.LCID)))
#endif
                                  + "\\" + "winrm.ini";
                if (File.Exists(filepath))
                {
                    FileStream   _fs = new FileStream(filepath, FileMode.Open, FileAccess.Read);
                    StreamReader _sr = new StreamReader(_fs);
                    while (!_sr.EndOfStream)
                    {
                        string Line = _sr.ReadLine();
                        if (Line.Contains("="))
                        {
                            string[] arr = Line.Split('=', count: 2);
                            if (!ResourceValueCache.ContainsKey(arr[0].Trim()))
                            {
                                string value = arr[1].Trim('"');
                                ResourceValueCache.Add(arr[0].Trim(), value.Trim());
                            }
                        }
                    }
                }
            }
            catch (IOException e)
            {
                throw (e);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Get the resource value from WinRm.ini
        /// from %windir%\system32\winrm\[Hexadecimal Language Folder]\winrm.ini
        /// </summary>
        /// <param name="Key"></param>
        /// <returns></returns>
        internal static string GetResourceString(string Key)
        {
            //Checks whether resource values already loaded and loads.
            if (ResourceValueCache.Count <= 0)
            {
                LoadResourceData();
            }
            string value = "";

            if (ResourceValueCache.ContainsKey(Key.Trim()))
            {
                ResourceValueCache.TryGetValue(Key.Trim(), out value);
            }
            return(value.Trim());
        }