本文整理汇总了C#中ImportContext.GetAttachmentStream方法的典型用法代码示例。如果您正苦于以下问题:C# ImportContext.GetAttachmentStream方法的具体用法?C# ImportContext.GetAttachmentStream怎么用?C# ImportContext.GetAttachmentStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImportContext
的用法示例。
在下文中一共展示了ImportContext.GetAttachmentStream方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportData
protected override void ImportData(XmlNode fieldNode, ImportContext context)
{
XmlAttribute attachmentAttr = fieldNode.Attributes["attachment"];
BinaryData binaryData = this.GetData() as BinaryData;
if (binaryData == null) binaryData = new BinaryData();
if (attachmentAttr == null)
{
binaryData.SetStream(Tools.GetStreamFromString(fieldNode.InnerXml));
binaryData.FileName = String.Concat(this.Content.ContentHandler.Name, ".", this.Name, ".txt");
}
else
{
string path = context.UnescapeFileName(attachmentAttr.Value);
binaryData.FileName = Path.Combine(context.CurrentDirectory, path);
//webdav request: we don't have a binary file
//next to the content as an attachment, so ignore the value
bool webdav = false;
if (HttpContext.Current != null)
{
string trans = HttpContext.Current.Request.Headers["Translate"];
webdav = (!string.IsNullOrEmpty(trans) && trans.ToLower().CompareTo("f") == 0);
}
if (!webdav)
{
var stream = context.GetAttachmentStream(path);
if (stream == null)
return;
binaryData.SetStream(stream);
}
}
this.SetData(binaryData);
}