示例#1
0
        public unsafe void Write(byte *pBuffer, long count)
        {
            Validate.Begin().IsNotNull(((void *)pBuffer), "pBuffer").IsNotNegative(count, "count").Check();
            long num = this.position + count;

            if (num < 0L)
            {
                throw new IOException($"stream too long, this.position + count = {this.position} + {count} = {num}");
            }
            if (num > this.length)
            {
                bool flag = this.position > this.length;
                if ((num > this.Capacity) && this.EnsureCapacity(num))
                {
                    flag = false;
                }
                if (flag)
                {
                    BufferUtil.ZeroMemory(this.buffer + ((byte *)this.length), num - this.length);
                }
                this.length = num;
            }
            byte *numPtr = this.buffer + ((byte *)this.position);

            Buffer.MemoryCopy((void *)pBuffer, (void *)numPtr, this.bufferSize, count);
            this.position += count;
        }
示例#2
0
 public override unsafe void SetLength(long value)
 {
     Validate.IsNotNegative(value, "value");
     if (!this.EnsureCapacity(value) && (value > this.length))
     {
         BufferUtil.ZeroMemory(this.buffer + ((byte *)this.length), value - this.length);
     }
     this.length = value;
     if (this.position > value)
     {
         this.position = value;
     }
 }
示例#3
0
 public override unsafe void WriteByte(byte value)
 {
     if (this.position >= this.length)
     {
         long desiredCapacity = this.position + 1L;
         bool flag            = this.position > this.length;
         if ((desiredCapacity >= this.Capacity) && this.EnsureCapacity(desiredCapacity))
         {
             flag = false;
         }
         if (flag)
         {
             BufferUtil.ZeroMemory(this.buffer + ((byte *)this.length), this.position - this.length);
         }
         this.length = desiredCapacity;
     }
     this.buffer[(int)this.position] = value;
     this.position += 1L;
 }