Example #1
0
        public void DataTypeToCycleDetector_Hierarchical()
        {
            var cycleDetector = new DataTypeToCycleDetector();

            // Any cyclic properties would be ignored on the parent class.
            Assert.IsNull(cycleDetector.Visit(DataType.FromType(typeof(DerivedCycle), allowCycles: true)));
        }
Example #2
0
        public void DataTypeToCycleDetector_OnlyCyclePaths()
        {
            var instance = new MyCyclicType
            {
                Inner = new InnerType
                {
                    Maker = new CycleMaker
                    {
                        Cycle = new MyCyclicType(),
                        Bar   = "bar",
                    },
                    Dummy = new DummyPath
                    {
                        Foo = 42,
                    }
                }
            };

            var cycleDetector = new DataTypeToCycleDetector();
            var expression    = (Expression <Action <object, HashSet <object> > >)cycleDetector.Visit(DataType.FromType(typeof(MyCyclicType), allowCycles: true));
            var compiled      = expression.Compile();

            compiled(instance, new HashSet <object>());
        }