Ejemplo n.º 1
0
 public static Hashtable getLocale(string moduleFolderPath)
 {            
     AppLocalized obj = new AppLocalized();
     string localFilePath = obj.FilePath(moduleFolderPath);            
     string fillString = string.Empty;
     localFilePath = HttpContext.Current.Server.MapPath(localFilePath);
     Hashtable hst = new Hashtable();
     if (File.Exists(localFilePath))
     {                
         using (StreamReader streamReader = File.OpenText(localFilePath))
         {
             string inputString = streamReader.ReadLine();
             while (inputString != null)
             {
                 string regexPattern = "(\"(?<key>[^\"]+)\"\\s*:\\s*\"(?<value>[^\"]+)\")|(\'(?<key>[^\']+)\'\\s*:\\s*\'(?<value>[^\']+)\')";
                 Regex regex = new Regex(regexPattern, RegexOptions.IgnorePatternWhitespace);
                 if (regex.IsMatch(inputString))
                 {
                     Match match = regex.Match(inputString);
                     string key = match.Groups[3].Value.Trim();
                     string value = match.Groups[4].Value.Trim();
                     if (hst[key] != null)
                     { }
                     else
                     {
                         hst.Add(key, value);
                     }
                 }
                 inputString = streamReader.ReadLine();
             }
         }
     }
     return hst;            
 }