Пример #1
0
        public void UnitTest2()
        {
            var tree = new XmlTreeStructure("node1", "DAV:",
                                            new Dictionary <string, string>
            {
                { "D", "DAV:" },
                { "C", "urn:ietf:params:xml: ns: caldav" }
            });

            tree.AddChild(new XmlTreeStructure("child1", null)).
            AddChild(new XmlTreeStructure("child2", null));
            IXMLTreeStructure child2;

            tree.GetChildAtAnyLevel("child2", out child2);
            child2.AddChild(new XmlTreeStructure("child3", null))
            .GetChild("child3").AddChild(new XmlTreeStructure("child4", null));
            IXMLTreeStructure child4;

            tree.GetChildAtAnyLevel("child4", out child4);
            child4.AddChild(new XmlTreeStructure("child5", null));
            var child6 = new XmlTreeStructure("child6", null);
            IXMLTreeStructure child5;

            tree.GetChildAtAnyLevel("child5", out child5);
            child5.AddChild(child6);
            IXMLTreeStructure child6_1;

            tree.GetChildAtAnyLevel("child6", out child6_1);
            IXMLTreeStructure test;

            tree.GetChildAtAnyLevel("prop", out test);

            Assert.Null(test);

            test = tree.GetChild("prop");

            Assert.Null(test);
            Assert.Equal(child6_1, child6);
        }
Пример #2
0
        /// <summary>
        ///     Extract all property names and property namespace from a include element of a  propfind body in the allproperty
        ///     method.
        /// </summary>
        /// <param name="propFindTree"></param>
        /// <returns></returns>
        private List <KeyValuePair <string, string> > ExtractIncludePropertiesNameMainNS(XmlTreeStructure propFindTree)
        {
            var retList = new List <KeyValuePair <string, string> >();
            IXMLTreeStructure includes;

            if (propFindTree.GetChildAtAnyLevel("include", out includes))
            {
                retList.AddRange(
                    includes.Children.Select(
                        child => new KeyValuePair <string, string>(child.NodeName, child.MainNamespace)));
            }
            return(retList);
        }