internal BrowserDefinition(XmlNode node, bool isDefaultBrowser) {
            if (node == null)
                throw new ArgumentNullException("node");

            _capabilities = new NameValueCollection();
            _idHeaderChecks = new ArrayList();
            _idCapabilityChecks = new ArrayList();
            _captureHeaderChecks = new ArrayList();
            _captureCapabilityChecks = new ArrayList();
            _adapters = new AdapterDictionary();
            _browsers = new BrowserDefinitionCollection();
            _gateways = new BrowserDefinitionCollection();
            _refBrowsers = new BrowserDefinitionCollection();
            _refGateways = new BrowserDefinitionCollection();
            _node = node;
            _isDefaultBrowser = isDefaultBrowser;

            string refID = null;

            HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "id", ref _id);
            HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "refID", ref refID);

            if((refID != null) && (_id != null)) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Browser_mutually_exclusive_attributes, "id", "refID"), node);
            }

            if (_id != null) {
                if (!System.CodeDom.Compiler.CodeGenerator.IsValidLanguageIndependentIdentifier(_id)) {
                    throw new ConfigurationErrorsException(SR.GetString(SR.Browser_InvalidID, "id", _id), node);
                }
            }
            else {
                if (refID == null) {
                    if (this is GatewayDefinition) {
                        throw new ConfigurationErrorsException(SR.GetString(SR.Browser_attributes_required, "gateway", "refID", "id"), node);
                    }

                    throw new ConfigurationErrorsException(SR.GetString(SR.Browser_attributes_required, "browser", "refID", "id"), node);
                }
                else {
                    if (!System.CodeDom.Compiler.CodeGenerator.IsValidLanguageIndependentIdentifier(refID)) {
                        throw new ConfigurationErrorsException(SR.GetString(SR.Browser_InvalidID, "refID", refID), node);
                    }
                }

                _parentID = refID;
                _isRefID = true;
                _id = refID;

                if (this is GatewayDefinition) {
                    _name = "refgatewayid$";
                }
                else {
                    _name = "refbrowserid$";
                }

                String parentID = null;
                HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "parentID", ref parentID);
                if ((parentID != null) && (parentID.Length != 0)) {
                    throw new ConfigurationErrorsException(SR.GetString(SR.Browser_mutually_exclusive_attributes, "parentID", "refID"), node);
                }
            }

            _name = MakeValidTypeNameFromString(_id + _name);

            if(!_isRefID) {
                // Not a default browser definition
                if (!("Default".Equals(_id))) {
                    HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "parentID", ref _parentID);
                }
                // Make sure parentID is not specified on default browser
                else {
                    HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "parentID", ref _parentID);
                    if (_parentID != null)
                        throw new ConfigurationErrorsException(
                            SR.GetString(SR.Browser_parentID_applied_to_default), node);
                }
            }

            _parentName = MakeValidTypeNameFromString(_parentID);

            if(_id.IndexOf(" ", StringComparison.Ordinal) != -1) {
                throw new ConfigurationErrorsException(SR.GetString(SR.Space_attribute, "id " + _id), node);
            }

            foreach(XmlNode child in node.ChildNodes) {
                if(child.NodeType != XmlNodeType.Element) {
                    continue;
                }

                switch (child.Name) {
                    case "identification":
                        // refID nodes do not allow <identification>
                        if (_isRefID) {
                            throw new ConfigurationErrorsException(SR.GetString(SR.Browser_refid_prohibits_identification), node);
                        }

                        this.ProcessIdentificationNode(child, BrowserCapsElementType.Identification);
                        break;

                    case "capture":
                        this.ProcessCaptureNode(child, BrowserCapsElementType.Capture);
                        break;

                    case "capabilities":
                        this.ProcessCapabilitiesNode(child);
                        break;

                    case "controlAdapters":
                        this.ProcessControlAdaptersNode(child);
                        break;

                    case "sampleHeaders":
                        break;

                    default:
                        throw new ConfigurationErrorsException(SR.GetString(SR.Browser_invalid_element, child.Name), node);
                }
            }
        }
        internal BrowserDefinition(System.Xml.XmlNode node, bool isDefaultBrowser)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            this._capabilities            = new NameValueCollection();
            this._idHeaderChecks          = new ArrayList();
            this._idCapabilityChecks      = new ArrayList();
            this._captureHeaderChecks     = new ArrayList();
            this._captureCapabilityChecks = new ArrayList();
            this._adapters         = new AdapterDictionary();
            this._browsers         = new BrowserDefinitionCollection();
            this._gateways         = new BrowserDefinitionCollection();
            this._refBrowsers      = new BrowserDefinitionCollection();
            this._refGateways      = new BrowserDefinitionCollection();
            this._node             = node;
            this._isDefaultBrowser = isDefaultBrowser;
            string val = null;

            System.Web.Configuration.HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "id", ref this._id);
            System.Web.Configuration.HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "refID", ref val);
            if ((val != null) && (this._id != null))
            {
                throw new ConfigurationErrorsException(System.Web.SR.GetString("Browser_mutually_exclusive_attributes", new object[] { "id", "refID" }), node);
            }
            if (this._id != null)
            {
                if (!CodeGenerator.IsValidLanguageIndependentIdentifier(this._id))
                {
                    throw new ConfigurationErrorsException(System.Web.SR.GetString("Browser_InvalidID", new object[] { "id", this._id }), node);
                }
            }
            else
            {
                if (val == null)
                {
                    if (this is GatewayDefinition)
                    {
                        throw new ConfigurationErrorsException(System.Web.SR.GetString("Browser_attributes_required", new object[] { "gateway", "refID", "id" }), node);
                    }
                    throw new ConfigurationErrorsException(System.Web.SR.GetString("Browser_attributes_required", new object[] { "browser", "refID", "id" }), node);
                }
                if (!CodeGenerator.IsValidLanguageIndependentIdentifier(val))
                {
                    throw new ConfigurationErrorsException(System.Web.SR.GetString("Browser_InvalidID", new object[] { "refID", val }), node);
                }
                this._parentID = val;
                this._isRefID  = true;
                this._id       = val;
                if (this is GatewayDefinition)
                {
                    this._name = "refgatewayid$";
                }
                else
                {
                    this._name = "refbrowserid$";
                }
                string str2 = null;
                System.Web.Configuration.HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "parentID", ref str2);
                if ((str2 != null) && (str2.Length != 0))
                {
                    throw new ConfigurationErrorsException(System.Web.SR.GetString("Browser_mutually_exclusive_attributes", new object[] { "parentID", "refID" }), node);
                }
            }
            this._name = MakeValidTypeNameFromString(this._id + this._name);
            if (!this._isRefID)
            {
                if (!"Default".Equals(this._id))
                {
                    System.Web.Configuration.HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "parentID", ref this._parentID);
                }
                else
                {
                    System.Web.Configuration.HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "parentID", ref this._parentID);
                    if (this._parentID != null)
                    {
                        throw new ConfigurationErrorsException(System.Web.SR.GetString("Browser_parentID_applied_to_default"), node);
                    }
                }
            }
            this._parentName = MakeValidTypeNameFromString(this._parentID);
            if (this._id.IndexOf(" ", StringComparison.Ordinal) != -1)
            {
                throw new ConfigurationErrorsException(System.Web.SR.GetString("Space_attribute", new object[] { "id " + this._id }), node);
            }
            foreach (System.Xml.XmlNode node2 in node.ChildNodes)
            {
                if (node2.NodeType == XmlNodeType.Element)
                {
                    string name = node2.Name;
                    if (name == null)
                    {
                        goto Label_03DA;
                    }
                    if (!(name == "identification"))
                    {
                        if (name == "capture")
                        {
                            goto Label_03BE;
                        }
                        if (name == "capabilities")
                        {
                            goto Label_03C8;
                        }
                        if (name == "controlAdapters")
                        {
                            goto Label_03D1;
                        }
                        if (name == "sampleHeaders")
                        {
                            continue;
                        }
                        goto Label_03DA;
                    }
                    if (this._isRefID)
                    {
                        throw new ConfigurationErrorsException(System.Web.SR.GetString("Browser_refid_prohibits_identification"), node);
                    }
                    this.ProcessIdentificationNode(node2, BrowserCapsElementType.Identification);
                }
                continue;
Label_03BE:
                this.ProcessCaptureNode(node2, BrowserCapsElementType.Capture);
                continue;
Label_03C8:
                this.ProcessCapabilitiesNode(node2);
                continue;
Label_03D1:
                this.ProcessControlAdaptersNode(node2);
                continue;
                Label_03DA :;
                throw new ConfigurationErrorsException(System.Web.SR.GetString("Browser_invalid_element", new object[] { node2.Name }), node);
            }
        }
        internal BrowserDefinition(XmlNode node, bool isDefaultBrowser)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            _capabilities            = new NameValueCollection();
            _idHeaderChecks          = new ArrayList();
            _idCapabilityChecks      = new ArrayList();
            _captureHeaderChecks     = new ArrayList();
            _captureCapabilityChecks = new ArrayList();
            _adapters         = new AdapterDictionary();
            _browsers         = new BrowserDefinitionCollection();
            _gateways         = new BrowserDefinitionCollection();
            _refBrowsers      = new BrowserDefinitionCollection();
            _refGateways      = new BrowserDefinitionCollection();
            _node             = node;
            _isDefaultBrowser = isDefaultBrowser;

            string refID = null;

            HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "id", ref _id);
            HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "refID", ref refID);

            if ((refID != null) && (_id != null))
            {
                throw new ConfigurationErrorsException(SR.GetString(SR.Browser_mutually_exclusive_attributes, "id", "refID"), node);
            }

            if (_id != null)
            {
                if (!System.CodeDom.Compiler.CodeGenerator.IsValidLanguageIndependentIdentifier(_id))
                {
                    throw new ConfigurationErrorsException(SR.GetString(SR.Browser_InvalidID, "id", _id), node);
                }
            }
            else
            {
                if (refID == null)
                {
                    if (this is GatewayDefinition)
                    {
                        throw new ConfigurationErrorsException(SR.GetString(SR.Browser_attributes_required, "gateway", "refID", "id"), node);
                    }

                    throw new ConfigurationErrorsException(SR.GetString(SR.Browser_attributes_required, "browser", "refID", "id"), node);
                }
                else
                {
                    if (!System.CodeDom.Compiler.CodeGenerator.IsValidLanguageIndependentIdentifier(refID))
                    {
                        throw new ConfigurationErrorsException(SR.GetString(SR.Browser_InvalidID, "refID", refID), node);
                    }
                }

                _parentID = refID;
                _isRefID  = true;
                _id       = refID;

                if (this is GatewayDefinition)
                {
                    _name = "refgatewayid$";
                }
                else
                {
                    _name = "refbrowserid$";
                }

                String parentID = null;
                HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "parentID", ref parentID);
                if ((parentID != null) && (parentID.Length != 0))
                {
                    throw new ConfigurationErrorsException(SR.GetString(SR.Browser_mutually_exclusive_attributes, "parentID", "refID"), node);
                }
            }

            _name = MakeValidTypeNameFromString(_id + _name);

            if (!_isRefID)
            {
                // Not a default browser definition
                if (!("Default".Equals(_id)))
                {
                    HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "parentID", ref _parentID);
                }
                // Make sure parentID is not specified on default browser
                else
                {
                    HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "parentID", ref _parentID);
                    if (_parentID != null)
                    {
                        throw new ConfigurationErrorsException(
                                  SR.GetString(SR.Browser_parentID_applied_to_default), node);
                    }
                }
            }

            _parentName = MakeValidTypeNameFromString(_parentID);

            if (_id.IndexOf(" ", StringComparison.Ordinal) != -1)
            {
                throw new ConfigurationErrorsException(SR.GetString(SR.Space_attribute, "id " + _id), node);
            }

            foreach (XmlNode child in node.ChildNodes)
            {
                if (child.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                switch (child.Name)
                {
                case "identification":
                    // refID nodes do not allow <identification>
                    if (_isRefID)
                    {
                        throw new ConfigurationErrorsException(SR.GetString(SR.Browser_refid_prohibits_identification), node);
                    }

                    this.ProcessIdentificationNode(child, BrowserCapsElementType.Identification);
                    break;

                case "capture":
                    this.ProcessCaptureNode(child, BrowserCapsElementType.Capture);
                    break;

                case "capabilities":
                    this.ProcessCapabilitiesNode(child);
                    break;

                case "controlAdapters":
                    this.ProcessControlAdaptersNode(child);
                    break;

                case "sampleHeaders":
                    break;

                default:
                    throw new ConfigurationErrorsException(SR.GetString(SR.Browser_invalid_element, child.Name), node);
                }
            }
        }
 internal BrowserDefinition(System.Xml.XmlNode node, bool isDefaultBrowser)
 {
     if (node == null)
     {
         throw new ArgumentNullException("node");
     }
     this._capabilities = new NameValueCollection();
     this._idHeaderChecks = new ArrayList();
     this._idCapabilityChecks = new ArrayList();
     this._captureHeaderChecks = new ArrayList();
     this._captureCapabilityChecks = new ArrayList();
     this._adapters = new AdapterDictionary();
     this._browsers = new BrowserDefinitionCollection();
     this._gateways = new BrowserDefinitionCollection();
     this._refBrowsers = new BrowserDefinitionCollection();
     this._refGateways = new BrowserDefinitionCollection();
     this._node = node;
     this._isDefaultBrowser = isDefaultBrowser;
     string val = null;
     System.Web.Configuration.HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "id", ref this._id);
     System.Web.Configuration.HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "refID", ref val);
     if ((val != null) && (this._id != null))
     {
         throw new ConfigurationErrorsException(System.Web.SR.GetString("Browser_mutually_exclusive_attributes", new object[] { "id", "refID" }), node);
     }
     if (this._id != null)
     {
         if (!CodeGenerator.IsValidLanguageIndependentIdentifier(this._id))
         {
             throw new ConfigurationErrorsException(System.Web.SR.GetString("Browser_InvalidID", new object[] { "id", this._id }), node);
         }
     }
     else
     {
         if (val == null)
         {
             if (this is GatewayDefinition)
             {
                 throw new ConfigurationErrorsException(System.Web.SR.GetString("Browser_attributes_required", new object[] { "gateway", "refID", "id" }), node);
             }
             throw new ConfigurationErrorsException(System.Web.SR.GetString("Browser_attributes_required", new object[] { "browser", "refID", "id" }), node);
         }
         if (!CodeGenerator.IsValidLanguageIndependentIdentifier(val))
         {
             throw new ConfigurationErrorsException(System.Web.SR.GetString("Browser_InvalidID", new object[] { "refID", val }), node);
         }
         this._parentID = val;
         this._isRefID = true;
         this._id = val;
         if (this is GatewayDefinition)
         {
             this._name = "refgatewayid$";
         }
         else
         {
             this._name = "refbrowserid$";
         }
         string str2 = null;
         System.Web.Configuration.HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "parentID", ref str2);
         if ((str2 != null) && (str2.Length != 0))
         {
             throw new ConfigurationErrorsException(System.Web.SR.GetString("Browser_mutually_exclusive_attributes", new object[] { "parentID", "refID" }), node);
         }
     }
     this._name = MakeValidTypeNameFromString(this._id + this._name);
     if (!this._isRefID)
     {
         if (!"Default".Equals(this._id))
         {
             System.Web.Configuration.HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "parentID", ref this._parentID);
         }
         else
         {
             System.Web.Configuration.HandlerBase.GetAndRemoveNonEmptyStringAttribute(node, "parentID", ref this._parentID);
             if (this._parentID != null)
             {
                 throw new ConfigurationErrorsException(System.Web.SR.GetString("Browser_parentID_applied_to_default"), node);
             }
         }
     }
     this._parentName = MakeValidTypeNameFromString(this._parentID);
     if (this._id.IndexOf(" ", StringComparison.Ordinal) != -1)
     {
         throw new ConfigurationErrorsException(System.Web.SR.GetString("Space_attribute", new object[] { "id " + this._id }), node);
     }
     foreach (System.Xml.XmlNode node2 in node.ChildNodes)
     {
         if (node2.NodeType == XmlNodeType.Element)
         {
             string name = node2.Name;
             if (name == null)
             {
                 goto Label_03DA;
             }
             if (!(name == "identification"))
             {
                 if (name == "capture")
                 {
                     goto Label_03BE;
                 }
                 if (name == "capabilities")
                 {
                     goto Label_03C8;
                 }
                 if (name == "controlAdapters")
                 {
                     goto Label_03D1;
                 }
                 if (name == "sampleHeaders")
                 {
                     continue;
                 }
                 goto Label_03DA;
             }
             if (this._isRefID)
             {
                 throw new ConfigurationErrorsException(System.Web.SR.GetString("Browser_refid_prohibits_identification"), node);
             }
             this.ProcessIdentificationNode(node2, BrowserCapsElementType.Identification);
         }
         continue;
     Label_03BE:
         this.ProcessCaptureNode(node2, BrowserCapsElementType.Capture);
         continue;
     Label_03C8:
         this.ProcessCapabilitiesNode(node2);
         continue;
     Label_03D1:
         this.ProcessControlAdaptersNode(node2);
         continue;
     Label_03DA:;
         throw new ConfigurationErrorsException(System.Web.SR.GetString("Browser_invalid_element", new object[] { node2.Name }), node);
     }
 }