Esempio n. 1
0
        protected void LoadIterative(XElement xelement, SubfolderDto subfolder)
        {
            itCounter++;
            var name = xelement.Name.ToString();

            if (xelement.Elements().Count() == 0)
            {
                return;
            }

            if (subfolder == null)
            {
                subfolder = new SubfolderDto {
                    Name = xelement.Name.ToString(), Parent = null
                };
                RetrieveCommentsAndAttributes(xelement, subfolder);
                Subfolders.Add(subfolder);
            }

            var list = xelement.Elements().ToList();

            for (int idx = 0; idx < list.Count(); idx++)
            {
                var elm = list[idx];
                var s1  = new SubfolderDto {
                    Name = elm.Name.ToString(), Parent = subfolder
                };
                RetrieveCommentsAndAttributes(elm, s1);
                subfolder.ChildFolder.Add(s1);
                Subfolders.Add(s1);
                LoadIterative(elm, s1);
            }
        }
Esempio n. 2
0
        public ConfigOrSettingsContent(XDocument xDocument)
        {
            this.xDocument = xDocument;
            SubfolderDto sf = null;

            LoadIterative(xDocument.Root, sf);
        }
Esempio n. 3
0
        protected void RetrieveCommentsAndAttributes(XElement xe, SubfolderDto sub)
        {
            var attributes = xe.Attributes();

            foreach (var at in attributes)
            {
                var attr = new AttributeDto {
                    Parent = sub, Name = at.Name.ToString(), Value = at.Value
                };
                sub.Attributes.Add(attr);
            }

            var comments = xe.Elements().OfType <XComment>();

            foreach (var comment in comments)
            {
                sub.Comments.Add(comment.Value);
            }
        }