protected void ProcessBrowserFiles(bool useVirtualPath, string virtualDir)
 {
     this._browserTree = new System.Web.Configuration.BrowserTree();
     this._defaultTree = new System.Web.Configuration.BrowserTree();
     this._customTreeNames = new ArrayList();
     if (this._browserFileList == null)
     {
         this._browserFileList = new ArrayList();
     }
     this._browserFileList.Sort();
     string str = null;
     string str2 = null;
     string str3 = null;
     foreach (string str4 in this._browserFileList)
     {
         if (str4.EndsWith("ie.browser", StringComparison.OrdinalIgnoreCase))
         {
             str2 = str4;
         }
         else if (str4.EndsWith("mozilla.browser", StringComparison.OrdinalIgnoreCase))
         {
             str = str4;
         }
         else if (str4.EndsWith("opera.browser", StringComparison.OrdinalIgnoreCase))
         {
             str3 = str4;
             break;
         }
     }
     if (str2 != null)
     {
         this._browserFileList.Remove(str2);
         this._browserFileList.Insert(0, str2);
     }
     if (str != null)
     {
         this._browserFileList.Remove(str);
         this._browserFileList.Insert(1, str);
     }
     if (str3 != null)
     {
         this._browserFileList.Remove(str3);
         this._browserFileList.Insert(2, str3);
     }
     foreach (string str5 in this._browserFileList)
     {
         XmlDocument document = new ConfigXmlDocument();
         try
         {
             document.Load(str5);
             XmlNode documentElement = document.DocumentElement;
             if (documentElement.Name != "browsers")
             {
                 if (useVirtualPath)
                 {
                     throw new HttpParseException(System.Web.SR.GetString("Invalid_browser_root"), null, virtualDir + "/" + this.NoPathFileName(str5), null, 1);
                 }
                 throw new HttpParseException(System.Web.SR.GetString("Invalid_browser_root"), null, str5, null, 1);
             }
             foreach (XmlNode node2 in documentElement.ChildNodes)
             {
                 if (node2.NodeType == XmlNodeType.Element)
                 {
                     if ((node2.Name == "browser") || (node2.Name == "gateway"))
                     {
                         this.ProcessBrowserNode(node2, this._browserTree);
                     }
                     else if (node2.Name == "defaultBrowser")
                     {
                         this.ProcessBrowserNode(node2, this._defaultTree);
                     }
                     else
                     {
                         System.Web.Configuration.HandlerBase.ThrowUnrecognizedElement(node2);
                     }
                 }
             }
         }
         catch (XmlException exception)
         {
             if (useVirtualPath)
             {
                 throw new HttpParseException(exception.Message, null, virtualDir + "/" + this.NoPathFileName(str5), null, exception.LineNumber);
             }
             throw new HttpParseException(exception.Message, null, str5, null, exception.LineNumber);
         }
         catch (XmlSchemaException exception2)
         {
             if (useVirtualPath)
             {
                 throw new HttpParseException(exception2.Message, null, virtualDir + "/" + this.NoPathFileName(str5), null, exception2.LineNumber);
             }
             throw new HttpParseException(exception2.Message, null, str5, null, exception2.LineNumber);
         }
     }
     this.NormalizeAndValidateTree(this._browserTree, false);
     this.NormalizeAndValidateTree(this._defaultTree, true);
     BrowserDefinition bd = (BrowserDefinition) this._browserTree["Default"];
     if (bd != null)
     {
         this.AddBrowserToCollectionRecursive(bd, 0);
     }
 }
 internal void ProcessCustomBrowserFiles(bool useVirtualPath, string virtualDir)
 {
     DirectoryInfo browserDirInfo = null;
     DirectoryInfo[] array = null;
     DirectoryInfo[] directories = null;
     this._customTreeList = new ArrayList();
     this._customBrowserFileLists = new ArrayList();
     this._customBrowserDefinitionCollections = new ArrayList();
     if (!useVirtualPath)
     {
         browserDirInfo = new DirectoryInfo(_browsersDirectory);
     }
     else
     {
         browserDirInfo = new DirectoryInfo(HostingEnvironment.MapPathInternal(virtualDir));
     }
     directories = browserDirInfo.GetDirectories();
     int index = 0;
     int length = directories.Length;
     array = new DirectoryInfo[length];
     for (int i = 0; i < length; i++)
     {
         if ((directories[i].Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
         {
             array[index] = directories[i];
             index++;
         }
     }
     Array.Resize<DirectoryInfo>(ref array, index);
     for (int j = 0; j < array.Length; j++)
     {
         FileInfo[] filesNotHidden = GetFilesNotHidden(array[j], browserDirInfo);
         if ((filesNotHidden != null) && (filesNotHidden.Length != 0))
         {
             System.Web.Configuration.BrowserTree tree = new System.Web.Configuration.BrowserTree();
             this._customTreeList.Add(tree);
             this._customTreeNames.Add(array[j].Name);
             ArrayList list = new ArrayList();
             foreach (FileInfo info2 in filesNotHidden)
             {
                 list.Add(info2.FullName);
             }
             this._customBrowserFileLists.Add(list);
         }
     }
     for (int k = 0; k < this._customBrowserFileLists.Count; k++)
     {
         ArrayList list2 = (ArrayList) this._customBrowserFileLists[k];
         foreach (string str in list2)
         {
             XmlDocument document = new ConfigXmlDocument();
             try
             {
                 document.Load(str);
                 XmlNode documentElement = document.DocumentElement;
                 if (documentElement.Name != "browsers")
                 {
                     if (useVirtualPath)
                     {
                         throw new HttpParseException(System.Web.SR.GetString("Invalid_browser_root"), null, virtualDir + "/" + this.NoPathFileName(str), null, 1);
                     }
                     throw new HttpParseException(System.Web.SR.GetString("Invalid_browser_root"), null, str, null, 1);
                 }
                 foreach (XmlNode node2 in documentElement.ChildNodes)
                 {
                     if (node2.NodeType == XmlNodeType.Element)
                     {
                         if ((node2.Name == "browser") || (node2.Name == "gateway"))
                         {
                             this.ProcessBrowserNode(node2, (System.Web.Configuration.BrowserTree) this._customTreeList[k]);
                         }
                         else
                         {
                             System.Web.Configuration.HandlerBase.ThrowUnrecognizedElement(node2);
                         }
                     }
                 }
             }
             catch (XmlException exception)
             {
                 if (useVirtualPath)
                 {
                     throw new HttpParseException(exception.Message, null, virtualDir + "/" + this.NoPathFileName(str), null, exception.LineNumber);
                 }
                 throw new HttpParseException(exception.Message, null, str, null, exception.LineNumber);
             }
             catch (XmlSchemaException exception2)
             {
                 if (useVirtualPath)
                 {
                     throw new HttpParseException(exception2.Message, null, virtualDir + "/" + this.NoPathFileName(str), null, exception2.LineNumber);
                 }
                 throw new HttpParseException(exception2.Message, null, str, null, exception2.LineNumber);
             }
         }
         this.SetCustomTreeRoots((System.Web.Configuration.BrowserTree) this._customTreeList[k], k);
         this.NormalizeAndValidateTree((System.Web.Configuration.BrowserTree) this._customTreeList[k], false, true);
         this._customBrowserDefinitionCollections.Add(new BrowserDefinitionCollection());
         this.AddCustomBrowserToCollectionRecursive((BrowserDefinition) ((System.Web.Configuration.BrowserTree) this._customTreeList[k])[this._customTreeNames[k]], 0, k);
     }
 }