本文整理汇总了C#中XDoc.WriteTo方法的典型用法代码示例。如果您正苦于以下问题:C# XDoc.WriteTo方法的具体用法?C# XDoc.WriteTo怎么用?C# XDoc.WriteTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XDoc
的用法示例。
在下文中一共展示了XDoc.WriteTo方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResourceContentBE
public ResourceContentBE(XDoc doc)
: this(true) {
if(doc == null) {
throw new ArgumentNullException("doc");
}
_stream = new ChunkedMemoryStream();
doc.WriteTo(_stream);
_mimeType = MimeType.TEXT_XML;
_size = (uint)_stream.Length;
}
示例2: CreateFileHandle
public static AwsS3FileHandle CreateFileHandle(XDoc data, TimeSpan? ttl)
{
var stream = new MemoryStream();
data.WriteTo(stream);
stream.Position = 0;
return new AwsS3FileHandle {
Expiration = null,
TimeToLive = ttl,
MimeType = MimeType.XML,
Modified = DateTime.UtcNow,
Size = stream.Length,
Stream = stream
};
}
示例3: Write_XDoc
public void Write_XDoc()
{
var doc = new XDoc("test").Start("content").Value("this is content").End();
var stream = new ChunkedMemoryStream();
doc.WriteTo(stream);
stream.Position = 0;
var newdoc = XDocFactory.From(stream, MimeType.XML);
Assert.AreEqual(doc, newdoc, "xdoc changed during serialization");
}
示例4: ToBytesVsWriteTo
public void ToBytesVsWriteTo()
{
XDoc doc = new XDoc("test").Attr("attr", 1).Elem("aaa", "1").Elem("bbb", "2").Elem("ccc", "3");
byte[] toBytes = doc.ToBytes();
MemoryStream mem = new MemoryStream();
doc.WriteTo(mem);
byte[] writeTo = mem.ToArray();
Assert.AreEqual(toBytes, writeTo);
}
示例5: XmlNullChar_in_xml_element_WriteTo
public void XmlNullChar_in_xml_element_WriteTo()
{
var doc = new XDoc("root").Value("foo\0bar");
var stream = new MemoryStream();
doc.WriteTo(stream, Encoding.UTF8);
Assert.AreEqual("<root>foobar</root>", new string(Encoding.UTF8.GetChars(stream.ToArray())));
}
示例6: XmlNullChar_in_xml_attribute_WriteTo
public void XmlNullChar_in_xml_attribute_WriteTo()
{
var doc = new XDoc("root").Attr("name", "foo\0bar");
var stream = new MemoryStream();
doc.WriteTo(stream, Encoding.UTF8);
Assert.AreEqual("<root name=\"foobar\" />", new string(Encoding.UTF8.GetChars(stream.ToArray())));
}