void ScanSectionsRecursive(XmlTextReader reader, string configKey)
        {
            int depth = reader.Depth;

            // only move to child nodes of not on first level (we've already passed the first <configsections>)
            if (configKey == null)
            {
                Debug.Assert(depth == 1);
                depth = 0;
            }
            else
            {
                StrictReadToNextElement(reader);
            }

            while (reader.Depth == depth + 1)
            {
                string tagName = reader.Name;
                string tagKey  = TagKey(configKey, tagName);

                HaveFactoryEnum haveFactory = HaveFactory(tagKey);

                if (haveFactory == HaveFactoryEnum.Group)
                {
                    ScanSectionsRecursive(reader, tagKey);
                    continue;
                }
                else if (haveFactory == HaveFactoryEnum.NotFound)
                {
                    if (tagKey == "location")
                    {
                    }
                    else if (tagKey == "configSections")
                    {
                        throw BuildConfigError(
                                  SR.GetString(SR.Client_config_too_many_configsections_elements),
                                  reader);
                    }
                    else
                    {
                        throw BuildConfigError(
                                  SR.GetString(SR.Unrecognized_configuration_section, tagName),
                                  reader);
                    }
                }
                else
                {
                    TraceVerbose("Adding section: " + tagKey);
                    if (_unevaluatedSections == null)
                    {
                        _unevaluatedSections = new Hashtable();
                    }

                    _unevaluatedSections[tagKey] = null;
                }
                StrictSkipToNextElement(reader);
            }
        }
Exemplo n.º 2
0
        private void ScanSectionsRecursive(XmlTextReader reader, string configKey)
        {
            int depth = reader.Depth;

            // only move to child nodes on first level (we've already passed the first <configSections>)
            if (configKey == null)
            {
                depth = 0;
            }
            else
            {
                StrictReadToNextElement(reader);
            }

            while (reader.Depth == depth + 1)
            {
                string tagName = reader.Name;
                string tagKey  = TagKey(configKey, tagName);

                HaveFactoryEnum haveFactory = HaveFactory(tagKey);

                if (haveFactory == HaveFactoryEnum.Group)
                {
                    ScanSectionsRecursive(reader, tagKey);
                    continue;
                }
                else if (haveFactory == HaveFactoryEnum.NotFound)
                {
                    if (tagKey != "location")
                    {
                    }
                    else if (tagKey == "configSections")
                    {
                        throw BuildConfigError("ClientConfig: too many ConfigSection elements", reader);
                    }
                    else
                    {
                        throw BuildConfigError("Unrecognized ConfigurationSection: " + tagName, reader);
                    }
                }
                else
                {
                    if (unevaluatedSections == null)
                    {
                        unevaluatedSections = new Hashtable();
                    }
                    unevaluatedSections[tagKey] = null;
                }
                StrictSkipToNextElement(reader);
            }
        }