示例#1
0
        public XmlDocument Write(Test test)
        {
            var document = new XmlDocument();

            var node = new TestXmlNode(document.WithRoot("Test"));
            new WriterVisitor(test, node).Write();

            return document;
        }
        public static void Write(SettingsData data, string filename)
        {
            var document = new XmlDocument();
            var root = document.WithRoot("Settings");
            root.SetAttribute("category", data.Category.ToString());

            data.AllKeys.Each(
                key => { root.AddElement("add").WithAtt("key", key).WithAtt("value", data[key].ToString()); });

            document.Save(filename);
        }
示例#3
0
        public static XmlElement WriteSpecRoot(Specification specification, XmlDocument document)
        {
            var root = document.WithRoot(Spec);
            root.SetAttribute(Id, specification.id);
            root.SetAttribute(MaxRetries, specification.MaxRetries.ToString());
            root.SetAttribute(TagsAtt, specification.Tags.Join(", "));
            root.SetAttribute(LifecycleAtt, specification.Lifecycle.ToString());
            root.SetAttribute(Name, specification.name);

            return root;
        }
示例#4
0
        public static XmlDocument XmlFromFileWithRoot(this string fileName, string root)
        {
            if (File.Exists(fileName))
            {
                return new XmlDocument().FromFile(fileName);
            }

            var document = new XmlDocument();
            document.WithRoot(root);

            return document;
        }
示例#5
0
        public XmlMediaDocument(XmlMediaOptions options)
        {
            _document = new XmlDocument();
            if (options.Namespace.IsEmpty())
            {
                _document.WithRoot(options.Root);
            }
            else
            {
                var node = _document.CreateNode(XmlNodeType.Element, options.Root, options.Namespace);
                _document.AppendChild(node);
            }

            _topNode = options.NodeStyle == XmlNodeStyle.AttributeCentric
                           ? (IXmlMediaNode) new XmlAttCentricMediaNode(_document.DocumentElement)
                           : new XmlNodeCentricMediaNode(_document.DocumentElement);

            _topNode.LinkWriter = options.LinkWriter;

            _options = options;
        }
        public void write_stream()
        {
            var document = new XmlDocument();
            document.WithRoot("root");

            theRecordedOutput.Write("text/xml", document.Save);
            theRecordedOutput.Outputs.First().ShouldEqual(new SetContentType("text/xml"));

            var writeStream = theRecordedOutput.Outputs.Last().ShouldBeOfType<WriteStream>();

            writeStream.ReadAll().ShouldEqual(document.OuterXml);
        }
        public void write_stream()
        {
            var document = new XmlDocument();
            document.WithRoot("root");

            theRecordedOutput.Write("text/xml", stream =>
            {
                document.Save(stream);
                return Task.CompletedTask;
            });

            theRecordedOutput.Outputs.First().ShouldBe(new SetContentType("text/xml"));

            var writeStream = theRecordedOutput.Outputs.Last().ShouldBeOfType<WriteStream>();

            writeStream.ReadAll().ShouldBe(document.OuterXml);
        }