コード例 #1
0
        public void live_binding_from_object_to_tree()
        {
            AlphaChi a = new AlphaChi();

            // Changing the object should materialize in tree
            PropertyTree pt = PropertyTree.FromValue(a, PropertyTreeValueOptions.Live);
            a.A = true;
            a.TT = new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.FromHours(-8));

            Assert.That(pt["A"].Value, Is.True);
            Assert.That(pt["TT"].Value, Is.EqualTo(a.TT));
        }
コード例 #2
0
        public void live_binding_from_tree_to_object()
        {
            AlphaChi a = new AlphaChi();

            PropertyTree pt = PropertyTree.FromValue(a, PropertyTreeValueOptions.Live);
            Assert.That(pt, Is.Not.Null);
            Assert.That(pt.Children.Count, Is.EqualTo(typeof(Alpha).GetProperties().Length));

            // Changing the tree should update the object
            pt["A"].Value = "true";
            pt["TT"].Value = "1/1/2000 12:00:00 AM -08:00";

            Assert.That(a.A, Is.True);
            Assert.That(a.TT, Is.EqualTo(new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.FromHours(-8))));
        }