Inheritance: IGraphWriter
示例#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()
                );
        }
示例#2
0
文件: GraphTests.cs 项目: sq/Fracture
        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()
            );
        }