The Labs \ Source Viewer \ SSCLI \ System.Net \ BufferOffsetSize

  1. //------------------------------------------------------------------------------
  2. // <copyright file="_BufferOffsetSize.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. namespace System.Net
  16. {
  17.     //
  18.     // this class is used by the BeginMultipleSend() API
  19.     // to allow a user to send multiple buffers on a socket
  20.     //
  21.     internal class BufferOffsetSize
  22.     {
  23.         //
  24.         // internal members
  25.         //
  26.         internal byte[] Buffer;
  27.         internal int Offset;
  28.         internal int Size;
  29.        
  30.         internal BufferOffsetSize(byte[] buffer, int offset, int size, bool copyBuffer)
  31.         {
  32.             GlobalLog.Assert(buffer != null && buffer.Length >= size + offset, "BufferOffsetSize::.ctor|Illegal parameters.");
  33.             if (copyBuffer) {
  34.                 byte[] newBuffer = new byte[size];
  35.                
  36.                     // src
  37.                     // src index
  38.                     // dest
  39.                     // dest index
  40.                 System.Buffer.BlockCopy(buffer, offset, newBuffer, 0, size);
  41.                 // total size to copy
  42.                 offset = 0;
  43.                 buffer = newBuffer;
  44.             }
  45.             Buffer = buffer;
  46.             Offset = offset;
  47.             Size = size;
  48.             GlobalLog.Print("BufferOffsetSize#" + ValidationHelper.HashString(this) + "::.ctor() copyBuffer:" + copyBuffer.ToString() + " this:[" + ToString() + "]");
  49.         }
  50.        
  51. /*
  52.         //                                   
  53.         internal BufferOffsetSize(byte[] buffer, int offset, bool copyBuffer)
  54.             : this(buffer, offset, buffer.Length - offset, copyBuffer) {
  55.         }
  56.         */       
  57.        
  58. /*
  59.         //                                   
  60.         internal BufferOffsetSize(int size, byte[] buffer, bool copyBuffer)
  61.             : this(buffer, 0, size, copyBuffer) {
  62.         }
  63.         */       
  64.        
  65.         internal BufferOffsetSize(byte[] buffer, bool copyBuffer) : this(buffer, 0, buffer.Length, copyBuffer)
  66.         {
  67.         }
  68.        
  69.        
  70.     }
  71.     // class BufferOffsetSize
  72.    
  73.    
  74. }
  75. // namespace System.Net

Developer Fusion