public PropertyTree ReadPropertyTree()
        {
            PropertyTreeNodeWriter nodeWriter = new PropertyTreeNodeWriter();

            this.CopyTo(nodeWriter);
            return(nodeWriter.Root);
        }
        public void document2()
        {
            PropertyTreeNodeWriter writer = new PropertyTreeNodeWriter();
            writer.WriteStartDocument();
            writer.WriteStartTree("hello");
            writer.WriteStartProperty("george");
            writer.WritePropertyValue("burdell");
            writer.WriteEndProperty();
            writer.WriteEndTree();
            writer.WriteEndDocument();

            Assert.That(writer.Root.Children.Count, Is.EqualTo(1));
            Assert.That(writer.Root.Children["george"], Is.Not.Null);
            Assert.That(writer.Root["george"], Is.Not.Null);
            Assert.That(writer.Root["george"].Value, Is.EqualTo("burdell"));
        }
Пример #3
0
        public override void CopyTo(PropertyNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (node.IsPropertyTree)
            {
                PropertyTreeWriter w = new PropertyTreeNodeWriter((PropertyTree)node);
                WriteTo(w);
            }
            else
            {
                // TODO Possible that Value isn't appropriate for Property
                Property p = (Property)node;
                p.QualifiedName = QualifiedName;
                p.Value         = Value;
            }
        }
        public void document3()
        {
            PropertyTreeNodeWriter writer = new PropertyTreeNodeWriter();
            writer.WriteStartDocument();
            writer.WriteStartTree("hello");

            writer.WriteStartProperty("george");
            writer.WritePropertyValue("burdell");
            writer.WriteEndProperty();

            writer.WriteStartProperty("buzz");
            writer.WritePropertyValue("234");
            writer.WriteEndProperty();

            writer.WriteProperty("hey", "arnold");

            writer.WriteEndTree();
            writer.WriteEndDocument();

            Assert.That(writer.Root.Children.Count, Is.EqualTo(3));
            Assert.That(writer.Root.Children.Select(t => t.Name).ToArray(), Is.EquivalentTo(new [] { "george", "buzz", "hey" }));
            Assert.That(writer.Root.Children["buzz"], Is.Not.Null);
            Assert.That(writer.Root["buzz"], Is.Not.Null);
        }
        public void trivial_document()
        {
            PropertyTreeNodeWriter writer = new PropertyTreeNodeWriter();
            writer.WriteStartDocument();
            writer.WriteEndDocument();

            Assert.That(writer.Root, Is.Null);
        }