public void CopyContentsFrom(PropertyTree tree)
        {
            if (tree == null)
                throw new ArgumentNullException("tree");

            tree.WriteContentsTo(this);
        }
        public void test_set_value_nominal()
        {
            PropertyTree p = new PropertyTree();
            p.SetValue("a", "420");

            Assert.That(p.GetInt16("a"), Is.EqualTo(420));
        }
        public void test_get_string_value_nominal()
        {
            PropertyTree p = new PropertyTree();
            p.AppendProperty("a", "text");

            Assert.That(p.GetString("a"), Is.EqualTo("text"));
        }
        public void test_get_boolean_value_implicit_conversion()
        {
            PropertyTree p = new PropertyTree();
            p.AppendProperty("a", "true");

            Assert.That(p.GetBoolean("a"), Is.True);
        }
        public PropertyTreeNodeWriter(PropertyTree tree)
        {
            if (tree == null)
                throw new ArgumentNullException("tree");

            this.currentParent = tree;
            this.root = tree;
        }
        public void test_append_to_nominal()
        {
            PropertyTree pt = new PropertyTree();
            Property p = new Property();
            p.AppendTo(pt);

            Assert.That(pt.FirstChild, Is.SameAs(p));
            Assert.That(p.Position, Is.EqualTo(0));
        }
        public void copy_from_object_to_tree()
        {
            Alpha a = new Alpha();
            a.A = true;
            a.TT = new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.FromHours(-8));

            PropertyTree p0 = new PropertyTree();
            PropertyTree pt = PropertyTree.FromValue(a);
            pt.CopyTo(p0);

            Assert.That(p0["A"].Value, Is.True);
            Assert.That(p0["TT"].Value, Is.EqualTo(a.TT));
        }
        public void binding_from_object_into_tree_value()
        {
            PropertyTree tree = new PropertyTree();
            Alpha a = new Alpha();
            a.A = true;
            a.TT = new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.FromHours(-8));
            tree.Value = a;

            Assert.That(tree.QualifiedName, Is.Null);
            Assert.That(tree.Children.Count, Is.EqualTo(typeof(Alpha).GetProperties().Length));
            Assert.That(tree.Children.Select(t => t.Name), Contains.Item("TT"));

            Assert.That(tree["TT"].Value, Is.EqualTo(a.TT));
            Assert.That(tree["A"].Value, Is.True);
        }
        public static PropertyTree FromValue(object value, PropertyTreeValueOptions options = PropertyTreeValueOptions.None)
        {
            if (value == null)
                throw new ArgumentNullException("value"); // $NON-NLS-1

            if (options.HasFlag(PropertyTreeValueOptions.Live))
                throw new NotImplementedException();

            // TODO Rework this to use PropertyTreeObjectReader
            PropertyTree result = new PropertyTree();
            var navigator = result.CreateNavigator();

            foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(value)) {
                object val = property.GetValue(value);
                if (!property.Converter.CanConvertTo(typeof(string)))
                    throw new NotImplementedException();

                navigator.AppendProperty(property.Name, val);
            }

            return result;
        }
 protected internal override void VisitPropertyTree(PropertyTree propertyTree)
 {
     foreach (var child in propertyTree.Children) {
         Visit(child);
     }
 }
        public override void WriteStartTree(string localName, string ns)
        {
            Require.NotNullOrEmptyString("localName", localName);
            StartImplicitly();
            PropertyTree newTree = new PropertyTree();
            newTree.Name = localName;
            newTree.Namespace = ns;
            CopyLineInfo(newTree);

            if (this.root == null) {
                this.root = newTree;
                this.currentParent = newTree;
            } else
                PushParent(newTree);
        }
 internal PropertyNodeLinkedList(PropertyTree parent)
 {
     this.parent = parent;
 }
 protected internal virtual void VisitPropertyTree(PropertyTree propertyTree)
 {
     DefaultVisit(propertyTree);
 }
 private void AssertBetaFile(PropertyTree tree)
 {
     Assert.That(tree.Name, Is.EqualTo("beta"));
     Assert.That(tree.FirstChild.Name, Is.EqualTo("c"));
     Assert.That(tree.Children[1].Name, Is.EqualTo("d"));
     Assert.That(tree.Children[2].Name, Is.EqualTo("a"));
     Assert.That(tree[2][1].Name, Is.EqualTo("aa"));
     Assert.That(tree[2][2].Name, Is.EqualTo("b"));
     Assert.That(tree[3][0].Name, Is.EqualTo("a"));
 }
        public void copy_property_tree_nominal()
        {
            PropertyTree a = new PropertyTree { Name = "a" };
            a.AppendProperty("x", 300);
            a.AppendProperty("y", 300);

            PropertyTree b = new PropertyTree();
            a.CopyTo(b);

            Assert.That(b.Name, Is.EqualTo("a"));
            Assert.That(b.Children.Count, Is.EqualTo(2));
            Assert.That(b.Children["x"].Value, Is.EqualTo(300));
            Assert.That(b.Children["y"].Value, Is.EqualTo(300));
        }