Exemplo n.º 1
0
        public static StructureInfo Execute(XDocument document)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }


            var rootElement = document.Root;
            var rootInfo    = new StructureInfo(rootElement.Name.LocalName);

            ParseRecursive(rootInfo, rootElement);
            DataInfoView.SourceCount = DevDataInfo.SourceCount = rootInfo.Childs.First().Childs.Max(x => x.Data.Count());

            return(rootInfo);
        }
Exemplo n.º 2
0
        private static void ParseRecursive(StructureInfo info, XElement element)
        {
            if (!element.Elements().Any())
            {
                info.AddData(element.Value);
            }

            foreach (var childElement in element.Elements())
            {
                var childInfo = info.Childs.SingleOrDefault(x => x.Name == childElement.Name.LocalName);
                if (childInfo == null)
                {
                    childInfo = new StructureInfo(childElement.Name.LocalName);
                    info.AddChild(childInfo);
                }
                ParseRecursive(childInfo, childElement);
            }
        }
Exemplo n.º 3
0
 public void AddChild(StructureInfo child)
 {
     ChildCollection.Add(child);
 }