コード例 #1
0
        public void Resolve_Container_List_Item()
        {
            var path      = PropertyPath.Parse("ChildContainer.ChildList[1].IntValue");
            var container = new TestNestedContainer
            {
                ChildContainer = new TestContainer
                {
                    IntValue  = 123,
                    ChildList =
                    {
                        new TestChildContainer {
                            IntValue = 123
                        },
                        new TestChildContainer {
                            IntValue = 456
                        }
                    }
                }
            };

            var resolution = path.Resolve(container);

            Assert.IsTrue(resolution.success);
            Assert.AreEqual(container.ChildContainer.ChildList[1], resolution.container);
            Assert.AreEqual(TestChildContainer.IntValueProperty, resolution.property);
            Assert.AreEqual(PropertyPath.InvalidListIndex, resolution.listIndex);
            Assert.AreEqual(456, resolution.value);
        }
コード例 #2
0
        public void PropertyContainer_SetValue_NestedContainer()
        {
            var container = new TestNestedContainer();

            PropertyContainer.SetValue(ref container, nameof(TestNestedContainer.TestPrimitiveContainer), new TestPrimitiveContainer {
                Int32Value = 42
            });

            Assert.AreEqual(42, container.TestPrimitiveContainer.Int32Value);
        }
コード例 #3
0
        public void PropertyContainer_GetValue_NestedContainer()
        {
            var container = new TestNestedContainer
            {
                TestPrimitiveContainer = new TestPrimitiveContainer
                {
                    Int32Value = 42
                }
            };

            var value = PropertyContainer.GetValue <TestNestedContainer, TestPrimitiveContainer>(ref container, nameof(TestNestedContainer.TestPrimitiveContainer));

            Assert.AreEqual(42, value.Int32Value);
        }
コード例 #4
0
        public void PropertyVisitor_Visit_StructWithNestedStruct()
        {
            var container = new TestNestedContainer();

            PropertyContainer.Visit(ref container, new DebugLogVisitor());
        }