コード例 #1
0
        internal static void PopulateNode(XmlNode sectionNode, NamedConfigurationElement element)
        {
            if (sectionNode.Attributes != null)
            {
                var valueAttr = sectionNode.Attributes["value"];
                if (valueAttr != null)
                {
                    element.Value = valueAttr.Value;
                }

                foreach (XmlAttribute attribute in sectionNode.Attributes)
                {
                    element.Attributes.Add(attribute.Name, attribute.Value);
                }
            }

            if (sectionNode.ChildNodes.Count > 0)
            {
                foreach (XmlNode childElement in sectionNode.ChildNodes)
                {
                    if (childElement.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }
                    AddSubElement(childElement, element);
                }
            }
        }
コード例 #2
0
        internal static void AddChildElement(XmlNode sectionNode, INamedElement parent, string name)
        {
            var element = new NamedConfigurationElement {
                Name = name
            };

            if (parent.Children.ContainsKey(name))
            {
                throw new ConfigurationErrorsException(string.Format(ADDS_REQUIRES_UNIQUE_NAME, sectionNode));
            }
            parent.Children.Add(name, element);

            PopulateNode(sectionNode, element);
        }
コード例 #3
0
        public DataConfig(INamedElement element)
        {
            if (element == null)
            {
                element = new NamedConfigurationElement()
                {
                    Name = SectionName
                }
            }
            ;
            Children   = element.Children;
            Attributes = element.Attributes;
            Name       = element.Name;

            if (Attributes.ContainsKey(DEFAULT_CONNECTION_STRING))
            {
                _default = Attributes[DEFAULT_CONNECTION_STRING];
            }
        }