本文整理汇总了C#中System.Net.Http.StreamContent.LoadIntoBufferAsync方法的典型用法代码示例。如果您正苦于以下问题:C# StreamContent.LoadIntoBufferAsync方法的具体用法?C# StreamContent.LoadIntoBufferAsync怎么用?C# StreamContent.LoadIntoBufferAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Http.StreamContent
的用法示例。
在下文中一共展示了StreamContent.LoadIntoBufferAsync方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadIntoBuffer_BufferOverflow
public void LoadIntoBuffer_BufferOverflow ()
{
var ms = new MemoryStream ();
ms.Write (new byte[10000], 0, 10000);
ms.Seek (0, SeekOrigin.Begin);
var sc = new StreamContent (ms);
try {
Assert.IsTrue (sc.LoadIntoBufferAsync (50).Wait (200));
Assert.Fail ("#1");
} catch (AggregateException e) {
Assert.IsInstanceOfType (typeof (HttpRequestException), e.InnerException, "#2");
}
}
示例2: LoadIntoBuffer
public void LoadIntoBuffer ()
{
var ms = new MemoryStream ();
ms.WriteByte (4);
ms.Seek (0, SeekOrigin.Begin);
var sc = new StreamContent (ms);
Assert.IsTrue (sc.LoadIntoBufferAsync (400).Wait (200));
}
示例3: ReadAsStreamAsync_ClosedInput
public void ReadAsStreamAsync_ClosedInput ()
{
var stream = new MemoryStream (new byte[] { 1 });
var content = new StreamContent (stream);
Assert.IsTrue (content.LoadIntoBufferAsync ().Wait (3000), "#1");
stream.Close ();
var stream_read = content.ReadAsStreamAsync ().Result;
Assert.IsTrue (stream_read.CanSeek, "#2");
Assert.AreEqual (0, stream_read.Position, "#3");
Assert.AreEqual (1, stream_read.Length, "#4");
}
示例4: ContentLengthAfterLoad
public void ContentLengthAfterLoad ()
{
var sc = new StreamContent (new CannotSeekStream ());
Assert.IsTrue (sc.LoadIntoBufferAsync ().Wait (3000), "#1");
Assert.AreEqual (11, sc.Headers.ContentLength, "#2");
}
示例5: CopyToAsync_ClosedInput
public void CopyToAsync_ClosedInput ()
{
var stream = new MemoryStream (new byte[] { 1 });
var content = new StreamContent (stream);
Assert.IsTrue (content.LoadIntoBufferAsync ().Wait (3000), "#1");
stream.Close ();
var stream_out = new MemoryStream (10);
Assert.IsTrue (content.CopyToAsync (stream_out).Wait (3000), "#2");
}