protected override void Init()
        {
            Serializer = new Serializer(new SerializerOptions(preserveObjectReferences: true));
            var a = new CyclicClassA();
            var b = new CyclicClassB();

            a.B    = b;
            b.A    = a;
            cyclic = a;

            virtualObject = new VirtualTestClass
            {
                DateProp   = DateTime.Now,
                GuidProp   = Guid.NewGuid(),
                IntProp    = 812342354,
                StringProp = new string('x', 30)
            };

            sealedObject = LargeSealedClass.MakeRandom();

            genericObject = new GenericClass <int, string, bool, DateTime, Guid>(123, "hello-world", true, DateTime.Now, Guid.NewGuid());
        }
示例#2
0
        protected override void Init()
        {
            var baseOptions = new SerializerOptions(preserveObjectReferences: true);

            Serializer = new Serializer(baseOptions);

            var filteredOptions = baseOptions
                                  .WithTypeFilter(
                TypeFilterBuilder.Create()
                .Include <CyclicClassA>()
                .Include <CyclicClassB>()
                .Include <VirtualTestClass>()
                .Include <LargeSealedClass>()
                .Include <GenericClass <int, string, bool, DateTime, Guid> >()
                .Include <TestEnum>()
                .Build());

            _filteredSerializer = new Serializer(filteredOptions);

            var a = new CyclicClassA();
            var b = new CyclicClassB();

            a.B    = b;
            b.A    = a;
            cyclic = a;

            virtualObject = new VirtualTestClass
            {
                DateProp   = DateTime.Now,
                GuidProp   = Guid.NewGuid(),
                IntProp    = 812342354,
                StringProp = new string('x', 30)
            };

            sealedObject = LargeSealedClass.MakeRandom();

            genericObject = new GenericClass <int, string, bool, DateTime, Guid>(123, "hello-world", true, DateTime.Now, Guid.NewGuid());
        }