Exemple #1
0
        private static XmlElement DumpWholeTree(this IDocLeaf leaf, string name, HashSet <object> alreadyDumped, XmlDocument doc)
        {
            bool seemsToBeAReference = alreadyDumped.Contains(leaf);

            XmlElement element = doc.CreateElement("Leaf");

            element.SetAttribute("Class", leaf.GetType().Name);
            element.SetAttribute("Name", name);
            element.SetAttribute("Owner", (!seemsToBeAReference).ToString());

            if (!seemsToBeAReference)
            {
                alreadyDumped.Add(leaf);

                if (leaf is DocBase)
                {
                    string[] names = PropertyUtils.NamesByType(leaf.GetType(), PropertyUtils.IsSupported);

                    foreach (var n in names)
                    {
                        IDocLeaf child = PropertyUtils.ByName(leaf, n) as IDocLeaf;

                        if (child != null)
                        {
                            element.AppendChild(child.DumpWholeTree(n, alreadyDumped, doc));
                        }
                    }
                }
                else if (leaf is IDocNode)
                {
                    foreach (var child in (leaf as IDocNode).Children())
                    {
                        if (child != null)
                        {
                            element.AppendChild(child.DumpWholeTree(child.Name, alreadyDumped, doc));
                        }
                    }
                }
            }

            return(element);
        }
Exemple #2
0
 public IDocLeaf ChildByName(string childName)
 {
     return(PropertyUtils.ByName(this, childName) as IDocLeaf);
 }