本文整理汇总了C#中IODataResponseMessage.GetStream方法的典型用法代码示例。如果您正苦于以下问题:C# IODataResponseMessage.GetStream方法的具体用法?C# IODataResponseMessage.GetStream怎么用?C# IODataResponseMessage.GetStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IODataResponseMessage
的用法示例。
在下文中一共展示了IODataResponseMessage.GetStream方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteEmptyResponse
/// <summary>
/// Write empty response and set the HttpStatusCode to 204 NoContent
/// </summary>
/// <param name="responseMessage"></param>
public static void WriteEmptyResponse(IODataResponseMessage responseMessage, HttpStatusCode statusCode = HttpStatusCode.NoContent)
{
responseMessage.SetStatusCode(statusCode);
responseMessage.SetHeader("OData-Version", "4.0");
if (!(responseMessage is ODataBatchOperationResponseMessage))
{
using (responseMessage.GetStream())
{
}
}
}
示例2: WriteAsyncPendingResponse
/// <summary>
/// Write empty response and set the HttpStatusCode to 202 Accepted
/// </summary>
/// <param name="responseMessage"></param>
/// <param name="asyncToken"></param>
public static void WriteAsyncPendingResponse(IODataResponseMessage responseMessage, string asyncToken)
{
responseMessage.SetStatusCode(HttpStatusCode.Accepted);
responseMessage.SetHeader(ServiceConstants.HttpHeaders.DataServiceVersion, "4.0");
Uri location = new Uri(ServiceConstants.ServiceBaseUri, string.Format("{0}?{1}={2}", ServiceConstants.ServicePath_Async, ServiceConstants.QueryOption_AsyncToken, asyncToken));
responseMessage.SetHeader(ServiceConstants.HttpHeaders.Location, location.OriginalString);
if (!(responseMessage is ODataBatchOperationResponseMessage))
{
using (responseMessage.GetStream())
{
}
}
}
示例3: HandleOperationResponseData
/// <summary>
/// copy the response data
/// </summary>
/// <param name="response">response object</param>
private void HandleOperationResponseData(IODataResponseMessage response)
{
Debug.Assert(response != null, "response != null");
using (Stream stream = response.GetStream())
{
if (null != stream)
{
// we need to check for whether the incoming stream was data or not. Hence we need to copy it to a temporary memory stream
using (MemoryStream memoryStream = new MemoryStream())
{
if (WebUtil.CopyStream(stream, memoryStream, ref this.buildBatchBuffer) != 0)
{
// set the memory stream position to zero again.
memoryStream.Position = 0;
this.HandleOperationResponseData(response, memoryStream);
}
else
{
this.HandleOperationResponseData(response, null);
}
}
}
}
}