Пример #1
0
        private XmlObject(XmlElement element, XmlObject parent, XmlDefinitionNode defNode)
        {
            Name           = element.Name;
            Parent         = parent;
            DefinitionNode = defNode;

            _attributes = element.Attributes.OfType <XmlAttribute>().ToDictionary(e => e.Name, e =>
                                                                                  defNode.SelectAttribute(e.Name).ReadValue(e.Value));

            var childrenGroup = element.ChildNodes.OfType <XmlElement>().GroupBy(e => e.Name).ToArray();

            _singleChildren =
                childrenGroup.Where(e => e.Count() == 1)
                .ToDictionary(e => e.Key, e => new XmlObject(e.First(), this, defNode.SelectNode(e.Key)));
            _multipleChildren =
                childrenGroup.Where(e => e.Count() > 1)
                .ToDictionary(e => e.Key,
                              e => e.Select(i => new XmlObject(i, this, defNode.SelectNode(i.Name))));
        }