Exemple #1
0
 internal static void ReadUserAgentsList()
 {
     try
     {
         XmlDocument UAL = new XmlDocument();
         UAL.XmlResolver = null;
         UAL.Load(string.Format("{0}//useragentswitcher.xml", Config.Path));
         Config.UserAgentsList = new Dictionary <string, Dictionary <string, string> >();
         foreach (XmlNode CategoryNode in UAL.SelectNodes("useragentswitcher")[0].SelectNodes("folder"))
         {
             string CategoryName = CategoryNode.Attributes["description"].Value;
             Dictionary <string, string> CurrentCategoryList = new Dictionary <string, string>();
             foreach (XmlNode UserAgentNode in CategoryNode.SelectNodes("useragent"))
             {
                 try
                 {
                     string Name      = UserAgentNode.Attributes["description"].Value;
                     string UserAgent = UserAgentNode.Attributes["useragent"].Value;
                     if (Name.Length > 0 && UserAgent.Length > 0)
                     {
                         CurrentCategoryList.Add(Name, UserAgent);
                     }
                 }
                 catch { }
             }
             foreach (XmlNode SubFolderNode in CategoryNode.SelectNodes("folder"))
             {
                 foreach (XmlNode SubUserAgentNode in SubFolderNode.SelectNodes("useragent"))
                 {
                     try
                     {
                         string Name      = SubUserAgentNode.Attributes["description"].Value;
                         string UserAgent = SubUserAgentNode.Attributes["useragent"].Value;
                         if (Name.Length > 0 && UserAgent.Length > 0)
                         {
                             CurrentCategoryList.Add(Name, UserAgent);
                         }
                     }
                     catch { }
                 }
             }
             if (CurrentCategoryList.Count > 0)
             {
                 Config.UserAgentsList[CategoryName] = CurrentCategoryList;
             }
         }
     }
     catch { }
 }