Ejemplo n.º 1
0
        public void ImmediateCircularReferenceDetection()
        {
            var context  = new ExportContext();
            var exporter = new ComponentExporter(typeof(Thing));

            context.Register(exporter);
            var thing = new Thing();

            thing.Other = thing;
            exporter.Export(context, thing, new EmptyJsonWriter());
        }
Ejemplo n.º 2
0
 public void CircularReferenceDetectionAcrossTypes()
 {
     ExportContext context = new ExportContext();
     ComponentExporter exporter = new ComponentExporter(typeof(Parent));
     context.Register(exporter);
     context.Register(new ComponentExporter(typeof(ParentChild)));
     Parent parent = new Parent();
     parent.Child = new ParentChild();
     parent.Child.Parent = parent;
     exporter.Export(context, parent, new EmptyJsonWriter());
 }
Ejemplo n.º 3
0
 public void DeepCircularReferenceDetection()
 {
     ExportContext context = new ExportContext();
     ComponentExporter exporter = new ComponentExporter(typeof(Thing));
     context.Register(exporter);
     Thing thing = new Thing();
     thing.Other = new Thing();
     thing.Other.Other = new Thing();
     thing.Other.Other.Other = thing;
     exporter.Export(context, thing, new EmptyJsonWriter());
 }
Ejemplo n.º 4
0
        public void CircularReferenceDetectionAcrossTypes()
        {
            ExportContext     context  = new ExportContext();
            ComponentExporter exporter = new ComponentExporter(typeof(Parent));

            context.Register(exporter);
            context.Register(new ComponentExporter(typeof(ParentChild)));
            Parent parent = new Parent();

            parent.Child        = new ParentChild();
            parent.Child.Parent = parent;
            exporter.Export(context, parent, new EmptyJsonWriter());
        }
Ejemplo n.º 5
0
        public void DeepCircularReferenceDetection()
        {
            ExportContext     context  = new ExportContext();
            ComponentExporter exporter = new ComponentExporter(typeof(Thing));

            context.Register(exporter);
            Thing thing = new Thing();

            thing.Other             = new Thing();
            thing.Other.Other       = new Thing();
            thing.Other.Other.Other = thing;
            exporter.Export(context, thing, new EmptyJsonWriter());
        }
Ejemplo n.º 6
0
        public void MemberExportCustomization()
        {
            var calls = new ArrayList();

            var logicalType = new TestTypeDescriptor();
            var properties  = logicalType.GetProperties();

            var memexp1  = new TestObjectMemberExporter(calls);
            var services = new Hashtable
            {
                [typeof(IObjectMemberExporter)] = memexp1
            };

            properties.Add(new TestPropertyDescriptor("prop1", services));

            var memexp2 = new TestObjectMemberExporter(calls);

            services = new Hashtable
            {
                [typeof(IObjectMemberExporter)] = memexp2
            };
            properties.Add(new TestPropertyDescriptor("prop2", services));

            var exporter = new ComponentExporter(typeof(Thing), logicalType);
            var context  = new ExportContext();

            context.Register(exporter);

            var writer = new JsonRecorder();
            var thing  = new Thing();

            context.Export(thing, writer);

            Assert.AreEqual(2, calls.Count);

            object[] args = { context, writer, thing };

            Assert.AreSame(memexp1, calls[0]);
            Assert.AreEqual(args, ((TestObjectMemberExporter)calls[0]).ExportArgs);

            Assert.AreSame(memexp2, calls[1]);
            Assert.AreEqual(args, ((TestObjectMemberExporter)calls[1]).ExportArgs);
        }
Ejemplo n.º 7
0
            public void Export(ExportContext context, JsonWriter writer)
            {
                var exporter = new ComponentExporter(typeof(Point), _componentType);

                exporter.Export(new ExportContext(), this, writer);
            }
Ejemplo n.º 8
0
 public void Export(ExportContext context, JsonWriter writer)
 {
     ComponentExporter exporter = new ComponentExporter(typeof(Point), _componentType);
     exporter.Export(new ExportContext(), this, writer);
 }
Ejemplo n.º 9
0
        public void MemberExportCustomization()
        {
            ArrayList calls = new ArrayList();

            TestTypeDescriptor logicalType = new TestTypeDescriptor();
            PropertyDescriptorCollection properties = logicalType.GetProperties();

            Hashtable services;

            TestObjectMemberExporter memexp1 = new TestObjectMemberExporter(calls);
            services = new Hashtable();
            services.Add(typeof(IObjectMemberExporter), memexp1);
            properties.Add(new TestPropertyDescriptor("prop1", services));

            TestObjectMemberExporter memexp2 = new TestObjectMemberExporter(calls);
            services = new Hashtable();
            services.Add(typeof(IObjectMemberExporter), memexp2);
            properties.Add(new TestPropertyDescriptor("prop2", services));

            ComponentExporter exporter = new ComponentExporter(typeof(Thing), logicalType);
            ExportContext context = new ExportContext();
            context.Register(exporter);

            JsonRecorder writer = new JsonRecorder();
            Thing thing = new Thing();
            context.Export(thing, writer);

            Assert.AreEqual(2, calls.Count);

            object[] args = { context, writer, thing };

            Assert.AreSame(memexp1, calls[0]);
            Assert.AreEqual(args, ((TestObjectMemberExporter) calls[0]).ExportArgs);

            Assert.AreSame(memexp2, calls[1]);
            Assert.AreEqual(args, ((TestObjectMemberExporter) calls[1]).ExportArgs);
        }
        public void MemberExportCustomization()
        {
            TestObjectMemberExporter memberExporter = new TestObjectMemberExporter();
            Hashtable services = new Hashtable();
            services.Add(typeof(IObjectMemberExporter), memberExporter);

            TestTypeDescriptor logicalType = new TestTypeDescriptor();
            PropertyDescriptorCollection properties = logicalType.GetProperties();
            properties.Add(new TestPropertyDescriptor("prop", services));
            
            ComponentExporter exporter = new ComponentExporter(typeof(Thing), logicalType);
            ExportContext context = new ExportContext();
            context.Register(exporter);
            
            JsonRecorder writer = new JsonRecorder();
            Thing thing = new Thing();
            context.Export(thing, writer);
            
            Assert.AreSame(context, memberExporter.ExportContext);
            Assert.AreSame(writer, memberExporter.ExportWriter);
            Assert.AreSame(thing, memberExporter.ExportSource);
        }