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


C# IInputStream.Read方法代码示例

本文整理汇总了C#中IInputStream.Read方法的典型用法代码示例。如果您正苦于以下问题:C# IInputStream.Read方法的具体用法?C# IInputStream.Read怎么用?C# IInputStream.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IInputStream的用法示例。


在下文中一共展示了IInputStream.Read方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadStringFromInputStream

 public bool ReadStringFromInputStream(IInputStream inputStream, List<string> messages, out string s)
 {
     var bytesCollection = new List<byte[]>();
     var bytes = new byte[Environment.SystemPageSize];
     while (true)
     {
         var bytesRead = inputStream.Read(bytes, _timeout);
         if (bytesRead <= 0) break;
         var bytesCopy = new byte[bytesRead];
         Buffer.BlockCopy(bytes, 0, bytesCopy, 0, bytesRead);
         bytesCollection.Add(bytesCopy);
     }
     var bytesCount = bytesCollection.Sum(bytesChunk => bytesChunk.Length);
     bytes = new byte[bytesCount];
     var offset = 0;
     foreach (var bytesChunk in bytesCollection)
     {
         Buffer.BlockCopy(bytesChunk, 0, bytes, offset, bytesChunk.Length);
         offset += bytesChunk.Length;
     }
     try
     {
         s = _encoding.GetString(bytes);
     }
     catch (Exception e)
     {
         messages.Add(e.ToString());
         s = null;
         return false;
     }
     return true;
 }
开发者ID:vlindos,项目名称:Vlindos,代码行数:32,代码来源:InputStreamStringReader.cs

示例2: Copy

		/// <exception cref="System.IO.IOException"></exception>
		protected virtual void Copy(IInputStream rawin, Socket4Adapter sock, bool update)
		{
			BufferedInputStream @in = new BufferedInputStream(rawin);
			byte[] buffer = new byte[BlobImpl.CopybufferLength];
			int bytesread = -1;
			while ((bytesread = rawin.Read(buffer)) >= 0)
			{
				sock.Write(buffer, 0, bytesread);
				if (update)
				{
					_currentByte += bytesread;
				}
			}
			@in.Close();
		}
开发者ID:Galigator,项目名称:db4o,代码行数:16,代码来源:MsgBlob.cs

示例3: Write

   public void Write(
 IInputStream data
 )
   {
       // TODO:IMPL bufferize!!!
         byte[] baseData = new byte[data.Length];
         // Force the source pointer to the BOF (as we must copy the entire content)!
         data.Position = 0;
         // Read source content!
         data.Read(baseData, 0, baseData.Length);
         // Write target content!
         Write(baseData);
   }
开发者ID:josuecorrea,项目名称:DanfeSharp,代码行数:13,代码来源:Stream.cs


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