當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。