Inheritance: IGraphWriter
Ejemplo n.º 1
0
        public void GraphXmlSerialization()
        {
            var root = new Node {
                Name = "root"
            };
            var childA = new Node {
                Name = "a"
            };
            var childB = new Node {
                Name = "b"
            };
            var subchildAA = new Node {
                Name = "a.a"
            };

            root.Children.AddLast(childA);
            root.Children.AddLast(childB);
            childA.Children.AddLast(subchildAA);

            var sb = new StringBuilder();

            using (var xwriter = XmlWriter.Create(sb, null)) {
                xwriter.WriteStartElement("test");
                var writer = new XmlGraphWriter(xwriter, new AssemblyTypeResolver(Assembly.GetExecutingAssembly()));
                root.Serialize(writer);
                xwriter.WriteEndElement();
            }

            Assert.AreEqual(
                GraphXML,
                sb.ToString()
                );
        }
Ejemplo n.º 2
0
        public void GraphXmlSerialization()
        {
            var root = new Node { Name = "root" };
            var childA = new Node { Name = "a" };
            var childB = new Node { Name = "b" };
            var subchildAA = new Node { Name = "a.a" };

            root.Children.AddLast(childA);
            root.Children.AddLast(childB);
            childA.Children.AddLast(subchildAA);

            var sb = new StringBuilder();
            using (var xwriter = XmlWriter.Create(sb, null)) {
                xwriter.WriteStartElement("test");
                var writer = new XmlGraphWriter(xwriter, new AssemblyTypeResolver(Assembly.GetExecutingAssembly()));
                root.Serialize(writer);
                xwriter.WriteEndElement();
            }

            Assert.AreEqual(
                GraphXML,
                sb.ToString()
            );
        }