当前位置: 首页>>代码示例>>C#>>正文


C# StreamContent.LoadIntoBufferAsync方法代码示例

本文整理汇总了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");
			}
		}
开发者ID:carrie901,项目名称:mono,代码行数:14,代码来源:StreamContentTest.cs

示例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));
		}
开发者ID:carrie901,项目名称:mono,代码行数:9,代码来源:StreamContentTest.cs

示例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");
		}
开发者ID:work-hrf,项目名称:mono,代码行数:12,代码来源:StreamContentTest.cs

示例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");
		}
开发者ID:work-hrf,项目名称:mono,代码行数:6,代码来源:StreamContentTest.cs

示例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");
		}
开发者ID:work-hrf,项目名称:mono,代码行数:10,代码来源:StreamContentTest.cs


注:本文中的System.Net.Http.StreamContent.LoadIntoBufferAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。