Exemplo n.º 1
0
        private void ReadConfigFile(XmlReader reader, string fileName)
        {
            reader.MoveToContent();

            if (reader.NodeType != XmlNodeType.Element || reader.Name != "configuration")
            {
                ThrowException("Configuration file does not have a valid root element", reader);
            }

            if (reader.HasAttributes)
            {
                while (reader.MoveToNextAttribute())
                {
                    if (reader.LocalName == "xmlns")
                    {
                        _rootNamespace = reader.Value;
                        continue;
                    }
                    ThrowException(string.Format("Unrecognized attribute '{0}' in root element", reader.LocalName),
                                   reader);
                }
            }

            reader.MoveToElement();

            if (reader.IsEmptyElement)
            {
                reader.Skip();
                return;
            }

            reader.ReadStartElement();
            reader.MoveToContent();

            if (reader.LocalName == "configSections")
            {
                if (reader.HasAttributes)
                {
                    ThrowException("Unrecognized attribute in <configSections>.", reader);
                }

                _rootGroup.ReadConfig(this, fileName, reader);
            }

            _rootGroup.ReadRootData(reader, this, true);
        }