本文整理汇总了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));
}
示例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("");
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例9: XDocInXStreamingElement
public void XDocInXStreamingElement()
{
InputSpace.Contacts(ref _xDoc, ref _xmlDoc);
XStreamingElement streamElement = new XStreamingElement("Root", _xDoc);
Assert.Throws<InvalidOperationException>(() => streamElement.Save(new MemoryStream()));
}
示例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));
}
示例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));
}
示例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));
}
示例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()));
}
示例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));
}
示例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("");
}