本文整理汇总了C#中MindTouch.Dream.DreamMessage.ToStream方法的典型用法代码示例。如果您正苦于以下问题:C# DreamMessage.ToStream方法的具体用法?C# DreamMessage.ToStream怎么用?C# DreamMessage.ToStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MindTouch.Dream.DreamMessage
的用法示例。
在下文中一共展示了DreamMessage.ToStream方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CouchContinuousChanges
internal CouchContinuousChanges(DreamMessage aMessage, CouchChangeDelegate aCallback)
{
if (aMessage == null)
throw new ArgumentNullException("aMessage");
if (aCallback == null)
throw new ArgumentNullException("aCallback");
theReader = new AsyncStreamReader(aMessage.ToStream(), (x, y) => {
if (!String.IsNullOrEmpty(y.Line))
{
CouchChangeResult result = theSerializer.Deserialize(y.Line);
aCallback(this, result);
}
});
}
示例2: GetRequestAsStream
private static object GetRequestAsStream(DreamContext context, DreamMessage request, Result<DreamMessage> response)
{
return request.ToStream();
}
示例3: AddAttachment
public Yield AddAttachment(DreamContext aContext, DreamMessage aRequest, Result<DreamMessage> aResponse)
{
Stream file = aRequest.ToStream();
Result<bool> result;
yield return result = Context.Current.Instance.ScoreController.AddAttachment(aContext.GetParam("id"), file,aRequest.ContentLength, aContext.GetParam("filename"), new Result<bool>());
aResponse.Return(DreamMessage.Ok());
}
示例4: CreateSourcePage
public Yield CreateSourcePage(DreamContext context, DreamMessage request, Result<DreamMessage> response)
{
if (request.ContentType.Match(MimeType.JSON))
{
ISourcePage page = Context.Current.Instance.SourcePageController.FromJson(request.ToText());
Result<ISourcePage> result = new Result<ISourcePage>();
yield return Context.Current.Instance.SourcePageController.Insert(page, result);
response.Return(DreamMessage.Ok(MimeType.JSON, Context.Current.Instance.SourcePageController.ToJson(result.Value)));
}
else // Bulk import based on ZIP file
{
Stream file = request.ToStream();
Result<bool> result = new Result<bool>();
yield return Context.Current.Instance.SourcePageController.BulkImportSourcePages(context.GetParam("sourceId"), file, result);
if (result.Value)
response.Return(DreamMessage.Ok());
else
response.Return(DreamMessage.BadRequest("Bad name format"));
}
}
示例5: AddFascimile
public Yield AddFascimile(DreamContext context, DreamMessage request, Result<DreamMessage> response)
{
Stream file = request.ToStream();
Result<bool> result;
yield return result = Context.Current.Instance.SourcePageController.AddFascimile(context.GetParam("sourcePageId"), file, request.ContentLength, new Result<bool>());
response.Return(DreamMessage.Ok());
}
示例6: SetRequestResult
private void SetRequestResult(DreamMessage result, XUri uri)
{
String tempfilename = String.Empty;
_cookies.Update(result.Cookies, uri);
txtHeaders.Clear();
foreach (KeyValuePair<string, string> header in result.Headers) {
txtHeaders.Text += header.Key + " = " + header.Value + Environment.NewLine;
}
foreach (DreamCookie c in result.Cookies) {
txtHeaders.Text += string.Format("Cookie: '{0}' Value: '{1}' Path: '{2}', Expires: '{3}' Domain: '{4}' {5}", c.Name, c.Value, c.Path, c.Expires, c.Domain, Environment.NewLine);
}
// if we received a file, save it
if (!String.IsNullOrEmpty(result.Headers[DreamHeaders.CONTENT_DISPOSITION])) {
String filename;
String[] contentInfoList = result.Headers[DreamHeaders.CONTENT_DISPOSITION].Split(';');
foreach (String contentInfo in contentInfoList) {
String trimmedContentInfo = contentInfo.Trim();
if (StringUtil.StartsWithInvariantIgnoreCase(trimmedContentInfo, "filename=")) {
filename = trimmedContentInfo.Substring(9);
filename = filename.Trim('"', '\\');
tempfilename = Path.Combine(Path.GetTempPath(), filename);
result.ToStream().CopyToFile(tempfilename, result.ContentLength);
}
}
} else {
tempfilename = Path.Combine(Path.GetTempPath(), DateTime.Now.Ticks.ToString()) + ".xml";
RegistryKey key = Registry.ClassesRoot.OpenSubKey("MIME\\Database\\Content Type\\" + result.ContentType.FullType);
if (null != key) {
tempfilename = tempfilename + key.GetValue("Extension");
key.Close();
}
File.WriteAllBytes(tempfilename, result.ToBytes());
}
// browse to the saved temporary file
if (!String.IsNullOrEmpty(tempfilename))
{
webBrowser.Url = new Uri(tempfilename);
}
else{
webBrowser.Url = null;
}
tabControl1.SelectedTab = resultsTabPage;
}