public override long Seek(long offset, SeekOrigin origin) { if (!this.CanSeek) { throw new InvalidOperationException(); } ThreadSafeStream.Node node = this.GetNode(); long num = 0L; switch (origin) { case SeekOrigin.Begin: num = offset; break; case SeekOrigin.Current: num = node.Position + offset; break; case SeekOrigin.End: num = this.Length + offset; break; } if (num < 0L || num > this.Length) { throw new ArgumentOutOfRangeException("offset"); } else { return(node.Position = num); } }
public override void Write(byte[] buffer, int offset, int count) { ThreadSafeStream.Node node = this.GetNode(); lock (this._streamLock) { if (this._baseStream.Position != node.Position) { this._baseStream.Position = node.Position; } this._baseStream.Write(buffer, offset, count); this._length = this._baseStream.Length; } node.Position += (long)count; }
public override int Read(byte[] buffer, int offset, int count) { ThreadSafeStream.Node node = this.GetNode(); int num; lock (this._streamLock) { if (this._baseStream.Position != node.Position) { this._baseStream.Position = node.Position; } num = this._baseStream.Read(buffer, offset, count); } node.Position += (long)num; return(num); }