當前位置: 首頁>>代碼示例>>C#>>正文


C# XStreamingElement.Save方法代碼示例

本文整理匯總了C#中System.Xml.Linq.XStreamingElement.Save方法的典型用法代碼示例。如果您正苦於以下問題:C# XStreamingElement.Save方法的具體用法?C# XStreamingElement.Save怎麽用?C# XStreamingElement.Save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.Linq.XStreamingElement的用法示例。


在下文中一共展示了XStreamingElement.Save方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: 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

示例2: XStreamingElementInXDocument

 //[Variation(Priority = 0, Desc = "XStreamingElement in XDocument")]
 public void XStreamingElementInXDocument()
 {
     _xDoc = new XDocument();
     XStreamingElement streamElement = new XStreamingElement("contacts", "SomeValue");
     _xDoc.Add(streamElement);
     getFreshStream();
     streamElement.Save(_sourceStream); _xDoc.Save(_targetStream);
     resetStreamPos();
     if (!_diff.Compare(_sourceStream, _targetStream))
         throw new TestFailedException("");
 }
開發者ID:nnyamhon,項目名稱:corefx,代碼行數:12,代碼來源:StreamingOutput.cs

示例3: 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

示例4: XStreamingElementInXDocument

 public void XStreamingElementInXDocument()
 {
     _xDoc = new XDocument();
     XStreamingElement streamElement = new XStreamingElement("contacts", "SomeValue");
     _xDoc.Add(streamElement);
     GetFreshStream();
     streamElement.Save(_sourceStream);
     _xDoc.Save(_targetStream);
     ResetStreamPos();
     Assert.True(Diff.Compare(_sourceStream, _targetStream));
 }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:11,代碼來源:StreamingOutput.cs

示例5: IEnumerableLazinessTest2

 public void IEnumerableLazinessTest2()
 {
     XElement name = new XElement("name", "jane");
     XElement phone = new XElement("phone", new XAttribute("type", "home"), "925-555-0134");
     XElement contact = new XElement("contact", name, phone);
     // During debug this test will not work correctly since ToString() of
     // streamElement gets called for displaying the value in debugger local window.
     XStreamingElement streamElement = new XStreamingElement("contact", GetElements(contact));
     GetFreshStream();
     contact.Save(_targetStream);
     _invokeStatus = true;
     streamElement.Save(_sourceStream);
     Assert.False(_invokeError, "IEnumerable walked before expected");
     ResetStreamPos();
     Assert.True(Diff.Compare(_sourceStream, _targetStream));
 }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:16,代碼來源:StreamingOutput.cs

示例6: NestedXStreamingElementPlusIEnumerable

 public void NestedXStreamingElementPlusIEnumerable()
 {
     InputSpace.Contacts(ref _xDoc, ref _xmlDoc);
     XElement element = new XElement("contacts", new XElement("Element", "Value"), _xDoc.Root.DescendantNodes());
     XStreamingElement streamElement = new XStreamingElement("contacts");
     streamElement.Add(new XStreamingElement("Element", "Value"), _xDoc.Root.DescendantNodes());
     GetFreshStream();
     streamElement.Save(_sourceStream);
     element.Save(_targetStream);
     ResetStreamPos();
     Assert.True(Diff.Compare(_sourceStream, _targetStream));
 }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:12,代碼來源:StreamingOutput.cs

示例7: ModifyOriginalElement

 public void ModifyOriginalElement()
 {
     XElement contact = new XElement(
         "contact",
         new XElement("name", "jane"),
         new XElement("phone", new XAttribute("type", "home"), "925-555-0134"));
     XStreamingElement streamElement = new XStreamingElement("contact", new object[] { contact.Elements() });
     foreach (XElement x in contact.Elements())
     {
         x.Remove();
     }
     GetFreshStream();
     streamElement.Save(_sourceStream);
     contact.Save(_targetStream);
     ResetStreamPos();
     Assert.True(Diff.Compare(_sourceStream, _targetStream));
 }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:17,代碼來源:StreamingOutput.cs

示例8: SaveWithXmlTextWriter

 public void SaveWithXmlTextWriter()
 {
     XElement contact = new XElement(
         "contacts",
         new XElement("contact", "jane"),
         new XElement("contact", "john"));
     XStreamingElement streamElement = new XStreamingElement("contacts", contact.Elements());
     GetFreshStream();
     TextWriter w = new StreamWriter(_sourceStream);
     streamElement.Save(w);
     w.Flush();
     contact.Save(_targetStream);
     ResetStreamPos();
     Assert.True(Diff.Compare(_sourceStream, _targetStream));
 }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:15,代碼來源:StreamingOutput.cs

示例9: XDocInXStreamingElement

 public void XDocInXStreamingElement()
 {
     InputSpace.Contacts(ref _xDoc, ref _xmlDoc);
     XStreamingElement streamElement = new XStreamingElement("Root", _xDoc);
     Assert.Throws<InvalidOperationException>(() => streamElement.Save(new MemoryStream()));
 }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:6,代碼來源:StreamingOutput.cs

示例10: XCommentInXStreamingElement

 public void XCommentInXStreamingElement()
 {
     XComment node = new XComment("This is a comment");
     XElement element = new XElement("Root", node);
     XStreamingElement streamElement = new XStreamingElement("Root", node);
     GetFreshStream();
     streamElement.Save(_sourceStream);
     element.Save(_targetStream);
     ResetStreamPos();
     Assert.True(Diff.Compare(_sourceStream, _targetStream));
 }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:11,代碼來源:StreamingOutput.cs

示例11: XCDataInXStreamingElement

 public void XCDataInXStreamingElement()
 {
     XCData node = new XCData("CDATA Text '%^$#@!&*()'");
     XElement element = new XElement("Root", node);
     XStreamingElement streamElement = new XStreamingElement("Root", node);
     GetFreshStream();
     streamElement.Save(_sourceStream);
     element.Save(_targetStream);
     ResetStreamPos();
     Assert.True(Diff.Compare(_sourceStream, _targetStream));
 }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:11,代碼來源:StreamingOutput.cs

示例12: XmlDeclInXStreamingElement

 public void XmlDeclInXStreamingElement()
 {
     XDeclaration node = new XDeclaration("1.0", "utf-8", "yes");
     XElement element = new XElement("Root", node);
     XStreamingElement streamElement = new XStreamingElement("Root", node);
     GetFreshStream();
     streamElement.Save(_sourceStream);
     element.Save(_targetStream);
     ResetStreamPos();
     Assert.True(Diff.Compare(_sourceStream, _targetStream));
 }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:11,代碼來源:StreamingOutput.cs

示例13: XDocTypeInXStreamingElement

        public void XDocTypeInXStreamingElement()
        {
            XDocumentType node = new XDocumentType(
                "DOCTYPE",
                "note",
                "SYSTEM",
                "<!ELEMENT note (to,from,heading,body)><!ELEMENT to (#PCDATA)><!ELEMENT from (#PCDATA)><!ELEMENT heading (#PCDATA)><!ELEMENT body (#PCDATA)>");

            XStreamingElement streamElement = new XStreamingElement("Root", node);
            Assert.Throws<InvalidOperationException>(() => streamElement.Save(new MemoryStream()));
        }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:11,代碼來源:StreamingOutput.cs

示例14: XNameAndEmptyStringConstructor

 public void XNameAndEmptyStringConstructor()
 {
     XElement contact = new XElement("contact", "");
     XStreamingElement streamElement = new XStreamingElement("contact", "");
     GetFreshStream();
     streamElement.Save(_sourceStream);
     contact.Save(_targetStream);
     ResetStreamPos();
     Assert.True(Diff.Compare(_sourceStream, _targetStream));
 }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:10,代碼來源:StreamingOutput.cs

示例15: XNameWithNamespaceConstructor

 //[Variation(Priority = 0, Desc = "Constructor - XStreamingElement(XName with Namespace)")]
 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();
     if (!_diff.Compare(_sourceStream, _targetStream))
         throw new TestFailedException("");
 }
開發者ID:nnyamhon,項目名稱:corefx,代碼行數:12,代碼來源:StreamingOutput.cs


注:本文中的System.Xml.Linq.XStreamingElement.Save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。