Наследование: System.Collections.Specialized.NameValueCollection
        internal static object CreateStatic(object parent, XmlNode section, string keyAttriuteName, string valueAttributeName)
        {
            ReadOnlyNameValueCollection result;

            // start result off as a shallow clone of the parent

            if (parent == null)
            {
                result = new ReadOnlyNameValueCollection(StringComparer.OrdinalIgnoreCase);
            }
            else
            {
                ReadOnlyNameValueCollection parentCollection = (ReadOnlyNameValueCollection)parent;
                result = new ReadOnlyNameValueCollection(parentCollection);
            }

            // process XML

            HandlerBase.CheckForUnrecognizedAttributes(section);

            foreach (XmlNode child in section.ChildNodes)
            {
                // skip whitespace and comments
                if (HandlerBase.IsIgnorableAlsoCheckForNonElement(child))
                {
                    continue;
                }

                // handle <set>, <remove>, <clear> tags
                if (child.Name == "add")
                {
                    String key   = HandlerBase.RemoveRequiredAttribute(child, keyAttriuteName);
                    String value = HandlerBase.RemoveRequiredAttribute(child, valueAttributeName, true /*allowEmptyString*/);
                    HandlerBase.CheckForUnrecognizedAttributes(child);

                    result[key] = value;
                }
                else if (child.Name == "remove")
                {
                    String key = HandlerBase.RemoveRequiredAttribute(child, keyAttriuteName);
                    HandlerBase.CheckForUnrecognizedAttributes(child);

                    result.Remove(key);
                }
                else if (child.Name.Equals("clear"))
                {
                    HandlerBase.CheckForUnrecognizedAttributes(child);
                    result.Clear();
                }
                else
                {
                    HandlerBase.ThrowUnrecognizedElement(child);
                }
            }

            result.SetReadOnly();

            return(result);
        }
        internal static object CreateStatic(object parent, XmlNode section, string keyAttriuteName, string valueAttributeName)
        {
            ReadOnlyNameValueCollection values;

            if (parent == null)
            {
                values = new ReadOnlyNameValueCollection(StringComparer.OrdinalIgnoreCase);
            }
            else
            {
                ReadOnlyNameValueCollection values2 = (ReadOnlyNameValueCollection)parent;
                values = new ReadOnlyNameValueCollection(values2);
            }
            HandlerBase.CheckForUnrecognizedAttributes(section);
            foreach (XmlNode node in section.ChildNodes)
            {
                if (!HandlerBase.IsIgnorableAlsoCheckForNonElement(node))
                {
                    if (node.Name == "add")
                    {
                        string str  = HandlerBase.RemoveRequiredAttribute(node, keyAttriuteName);
                        string str2 = HandlerBase.RemoveRequiredAttribute(node, valueAttributeName, true);
                        HandlerBase.CheckForUnrecognizedAttributes(node);
                        values[str] = str2;
                    }
                    else if (node.Name == "remove")
                    {
                        string name = HandlerBase.RemoveRequiredAttribute(node, keyAttriuteName);
                        HandlerBase.CheckForUnrecognizedAttributes(node);
                        values.Remove(name);
                    }
                    else if (node.Name.Equals("clear"))
                    {
                        HandlerBase.CheckForUnrecognizedAttributes(node);
                        values.Clear();
                    }
                    else
                    {
                        HandlerBase.ThrowUnrecognizedElement(node);
                    }
                }
            }
            values.SetReadOnly();
            return(values);
        }
 internal static object CreateStatic(object parent, XmlNode section, string keyAttriuteName, string valueAttributeName)
 {
     ReadOnlyNameValueCollection values;
     if (parent == null)
     {
         values = new ReadOnlyNameValueCollection(StringComparer.OrdinalIgnoreCase);
     }
     else
     {
         ReadOnlyNameValueCollection values2 = (ReadOnlyNameValueCollection) parent;
         values = new ReadOnlyNameValueCollection(values2);
     }
     HandlerBase.CheckForUnrecognizedAttributes(section);
     foreach (XmlNode node in section.ChildNodes)
     {
         if (!HandlerBase.IsIgnorableAlsoCheckForNonElement(node))
         {
             if (node.Name == "add")
             {
                 string str = HandlerBase.RemoveRequiredAttribute(node, keyAttriuteName);
                 string str2 = HandlerBase.RemoveRequiredAttribute(node, valueAttributeName, true);
                 HandlerBase.CheckForUnrecognizedAttributes(node);
                 values[str] = str2;
             }
             else if (node.Name == "remove")
             {
                 string name = HandlerBase.RemoveRequiredAttribute(node, keyAttriuteName);
                 HandlerBase.CheckForUnrecognizedAttributes(node);
                 values.Remove(name);
             }
             else if (node.Name.Equals("clear"))
             {
                 HandlerBase.CheckForUnrecognizedAttributes(node);
                 values.Clear();
             }
             else
             {
                 HandlerBase.ThrowUnrecognizedElement(node);
             }
         }
     }
     values.SetReadOnly();
     return values;
 }
Пример #4
0
        internal static Object Create(Object parent, XmlNode section,
                                      String keyName, String valueName)
        {
            ReadOnlyNameValueCollection coll;
            String key, value;

            // Create the name/value collection for the result.
            if (parent != null)
            {
                coll = new ReadOnlyNameValueCollection
                           ((NameValueCollection)parent);
            }
            else
            {
                coll = new ReadOnlyNameValueCollection();
            }

            // Must not be any attributes remaining on the section node.
            if (section.Attributes.Count != 0)
            {
                throw new ConfigurationException
                          (S._("Config_UnrecognizedAttribute"), section);
            }

            // Process the child nodes.
            foreach (XmlNode node in section.ChildNodes)
            {
                // Ignore comments and white space.
                if (node.NodeType == XmlNodeType.Comment ||
                    node.NodeType == XmlNodeType.Whitespace ||
                    node.NodeType == XmlNodeType.SignificantWhitespace)
                {
                    continue;
                }

                // Must be an element node.
                if (node.NodeType != XmlNodeType.Element)
                {
                    throw new ConfigurationException
                              (S._("Config_MustBeElement"), node);
                }

                // Process "add", "remove", and "clear" child tags.
                if (node.Name == "add")
                {
                    key       = GetRequiredAttribute(node, keyName, 1);
                    value     = GetRequiredAttribute(node, valueName, 0);
                    coll[key] = value;
                }
                else if (node.Name == "remove")
                {
                    key = GetRequiredAttribute(node, keyName, 0);
                    coll.Remove(key);
                }
                else if (node.Name == "clear")
                {
                    if (node.Attributes.Count != 0)
                    {
                        throw new ConfigurationException
                                  (S._("Config_UnrecognizedAttribute"), node);
                    }
                    coll.Clear();
                }
                else
                {
                    throw new ConfigurationException
                              (S._("Config_NotRecognized"), node);
                }
            }

            // Make the collection read-only and return it.
            coll.MakeReadOnly();
            return(coll);
        }
Пример #5
0
 internal ReadOnlyNameValueCollection(ReadOnlyNameValueCollection value) : base(value)
 {
 }
 public ReadOnlyNameValueCollection(ReadOnlyNameValueCollection value) : base(value)
 {
 }