当前位置: 首页>>代码示例>>C#>>正文


C# Linq.XStreamingElement类代码示例

本文整理汇总了C#中System.Xml.Linq.XStreamingElement的典型用法代码示例。如果您正苦于以下问题:C# XStreamingElement类的具体用法?C# XStreamingElement怎么用?C# XStreamingElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


XStreamingElement类属于System.Xml.Linq命名空间,在下文中一共展示了XStreamingElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: XElement

		public XElement (XStreamingElement other)
		{
			if (other == null)
				throw new ArgumentNullException ("other");
			this.name = other.Name;
			Add (other.Contents);
		}
开发者ID:work-hrf,项目名称:mono,代码行数:7,代码来源:XElement.cs

示例2: WriteFile

        private void WriteFile(string targetDirectory, string entityNames, XStreamingElement fileContents)
        {
            var fileContentsWithHeader = @"<?xml version=""1.0"" encoding=""utf-8""?>" + Environment.NewLine + fileContents;

            var path = Path.Combine(targetDirectory, entityNames + ".xml");
            if (File.Exists(path))
            {
                var existingFileContents = File.ReadAllText(path);
                if (existingFileContents == fileContentsWithHeader)
                {
                    return;
                }

                var backupFolder = Path.Combine(targetDirectory, @"backup\");
                Directory.CreateDirectory(backupFolder);

                var fileNumber = GetFileNumber(backupFolder, entityNames);
                var backupFileName = String.Format("{0}.backup-{1}.xml", entityNames, fileNumber);

                var backupPath = Path.Combine(backupFolder, backupFileName);
                File.Move(path, backupPath);
            }

            File.WriteAllText(path, fileContentsWithHeader);
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:25,代码来源:FileWriter.cs

示例3: ToStringAttributeAfterText

		public void ToStringAttributeAfterText ()
		{
			var el = new XStreamingElement ("foo",
				"text",
				new XAttribute ("bar", "baz"));
			el.ToString ();
		}
开发者ID:nobled,项目名称:mono,代码行数:7,代码来源:XStreamingElementTest.cs

示例4: ToString

		public void ToString ()
		{
			var el = new XStreamingElement ("foo",
				new XAttribute ("bar", "baz"),
				"text");
			Assert.AreEqual ("<foo bar=\"baz\">text</foo>", el.ToString ());
		}
开发者ID:nobled,项目名称:mono,代码行数:7,代码来源:XStreamingElementTest.cs

示例5: XNameWithNamespaceConstructor

 public void XNameWithNamespaceConstructor()
 {
     XNamespace ns = @"http:\\www.contacts.com\";
     XElement contact = new XElement(ns + "contact");
     XStreamingElement streamElement = new XStreamingElement(ns + "contact");
     GetFreshStream();
     streamElement.Save(_sourceStream);
     contact.Save(_targetStream);
     ResetStreamPos();
     Assert.True(Diff.Compare(_sourceStream, _targetStream));
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:11,代码来源:StreamingOutput.cs

示例6: XNameAsEmptyStringConstructor

 //[Variation(Priority = 1, Desc = "Constructor - XStreamingElement('')")]
 public void XNameAsEmptyStringConstructor()
 {
     try
     {
         XStreamingElement streamElement = new XStreamingElement(" ");
     }
     catch (System.Xml.XmlException)
     {
         return;
     }
     throw new TestFailedException("");
 }
开发者ID:nnyamhon,项目名称:corefx,代码行数:13,代码来源:StreamingOutput.cs

示例7: XNameAsNullConstructor

 //[Variation(Priority = 1, Desc = "Constructor - XStreamingElement(null)")]
 public void XNameAsNullConstructor()
 {
     try
     {
         XStreamingElement streamElement = new XStreamingElement(null);
     }
     catch (System.ArgumentNullException)
     {
         return;
     }
     throw new TestFailedException("");
 }
开发者ID:nnyamhon,项目名称:corefx,代码行数:13,代码来源:StreamingOutput.cs

示例8: WriteXStreamingElementChildren

		public void WriteXStreamingElementChildren ()
		{
			var xml = "<?xml version='1.0' encoding='utf-8'?><root type='array'><item type='number'>0</item><item type='number'>2</item><item type='number'>5</item></root>".Replace ('\'', '"');
			
			var ms = new MemoryStream ();
			var xw = XmlWriter.Create (ms);
			int [] arr = new int [] {0, 2, 5};
			var xe = new XStreamingElement (XName.Get ("root"));
			xe.Add (new XAttribute (XName.Get ("type"), "array"));
			var at = new XAttribute (XName.Get ("type"), "number");
			foreach (var i in arr)
				xe.Add (new XStreamingElement (XName.Get ("item"), at, i));

			xe.WriteTo (xw);
			xw.Close ();
			Assert.AreEqual (xml, new StreamReader (new MemoryStream (ms.ToArray ())).ReadToEnd (), "#1");
		}
开发者ID:nobled,项目名称:mono,代码行数:17,代码来源:XStreamingElementTest.cs

示例9: WriteAccounts_creates_a_backup_and_overwrites_Account_file_if_it_has_changed

        public void WriteAccounts_creates_a_backup_and_overwrites_Account_file_if_it_has_changed()
        {
            _fileWriter.WriteAccountFile(TestDirectory);
            var originalTimestamp = File.GetLastWriteTimeUtc(_expectedAccountPath);

            Thread.Sleep(10);

            var modifiedAccountXml = new XStreamingElement("test", "someDifferentContent");
            _accountRepository.EmitXml().Returns(modifiedAccountXml);
            _fileWriter.WriteAccountFile(TestDirectory);

            var timestampAfterSecondWrite = File.GetLastWriteTimeUtc(_expectedAccountPath);

            Assert.AreNotEqual(originalTimestamp, timestampAfterSecondWrite);

            var backupPath = Path.Combine(TestDirectory, @"backup\", "accounts.backup-1.xml");

            Assert.IsTrue(File.Exists(backupPath));
            Assert.AreEqual(_accountXml.ToString(), File.ReadAllText(backupPath));
            Assert.AreEqual(originalTimestamp, File.GetLastWriteTimeUtc(backupPath));
        }
开发者ID:mattwatson,项目名称:Akcounts,代码行数:21,代码来源:FileWriter_spec.cs

示例10: WriteStreamingElement

 internal void WriteStreamingElement(XStreamingElement e)
 {
     FlushElement();
     _element = e;
     Write(e.content);
     bool contentWritten = _element == null;
     FlushElement();
     if (contentWritten)
     {
         _writer.WriteFullEndElement();
     }
     else
     {
         _writer.WriteEndElement();
     }
     _resolver.PopScope();
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:17,代码来源:XLinq.cs

示例11: XNameAndNullObjectConstructor

 public void XNameAndNullObjectConstructor()
 {
     XStreamingElement streamElement = new XStreamingElement("contact", null);
     Assert.Equal("<contact />", streamElement.ToString());
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:5,代码来源:StreamingOutput.cs

示例12: XElement

		public XElement (XStreamingElement other)
		{
			this.name = other.Name;
			Add (other.Contents);
		}
开发者ID:user277,项目名称:mono,代码行数:5,代码来源:XElement.cs

示例13: XNameAndXElementObjectConstructor

 public void XNameAndXElementObjectConstructor()
 {
     XElement contact = new XElement("contact", new XElement("phone", "925-555-0134"));
     XStreamingElement streamElement = new XStreamingElement("contact", contact.Element("phone"));
     GetFreshStream();
     streamElement.Save(_sourceStream);
     contact.Save(_targetStream);
     ResetStreamPos();
     Assert.True(Diff.Compare(_sourceStream, _targetStream));
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:10,代码来源:StreamingOutput.cs

示例14: XStreamingElementSave_SaveOptions

 public void XStreamingElementSave_SaveOptions()
 {
     string markup = "<e a=\"value\"> <!--comment--> <e2> <![CDATA[cdata]]> </e2> <?pi target?> </e>";
     try
     {
         XElement e = XElement.Parse(markup, LoadOptions.PreserveWhitespace);
         XStreamingElement e2 = new XStreamingElement(e.Name, e.Attributes(), e.Nodes());
         e2.Save(_fileName, SaveOptions.DisableFormatting);
     }
     finally
     {
         Assert.True(File.Exists(_fileName));
         Assert.Equal("<?xml version=\"1.0\" encoding=\"utf-8\"?>" + markup, File.ReadAllText(_fileName));
         File.Delete(_fileName);
     }
 }
开发者ID:dotnet,项目名称:corefx,代码行数:16,代码来源:SaveWithFileName.cs

示例15: MakeItems

 private XStreamingElement MakeItems()
 {
     XStreamingElement items = new XStreamingElement(Xmlns + "Items", MakeItemsContent());
     return items;
 }
开发者ID:JuliettAlex,项目名称:Sales,代码行数:5,代码来源:CxmlSerializer.cs


注:本文中的System.Xml.Linq.XStreamingElement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。