本文整理汇总了C#中IResource.GetStream方法的典型用法代码示例。如果您正苦于以下问题:C# IResource.GetStream方法的具体用法?C# IResource.GetStream怎么用?C# IResource.GetStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IResource
的用法示例。
在下文中一共展示了IResource.GetStream方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AssertResourceContent
/// <summary>
/// Utility method to compare a resource that contains a single string with an exemplar.
/// </summary>
/// <param name="res">The resource to read a line from</param>
/// <param name="expectedContent">the expected value of the line.</param>
private void AssertResourceContent(IResource res, string expectedContent)
{
using (StreamReader reader = new StreamReader(res.GetStream()))
{
Assert.AreEqual(expectedContent, reader.ReadLine(), "Resource content is not as expected");
}
}
示例2: CreateWith
/// <summary>
/// Creates a <see cref="ResponseCreator"/> that respond with
/// the given response body (from a <see cref="IResource"/>), headers, status code, and status description.
/// </summary>
/// <param name="body">The <see cref="IResource"/> containing the body of the response.</param>
/// <param name="headers">The response headers.</param>
/// <param name="statusCode">The response status code.</param>
/// <param name="statusDescription">The response status description.</param>
/// <returns>A <see cref="ResponseCreator"/>.</returns>
public static ResponseCreator CreateWith(
IResource body, HttpHeaders headers, HttpStatusCode statusCode, string statusDescription)
{
ArgumentUtils.AssertNotNull(body, "body");
return delegate(IClientHttpRequest request)
{
return new MockClientHttpResponse(body.GetStream(), headers, statusCode, statusDescription);
};
}