protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         ParentStream.Dispose();
     }
 }
            public override int Read(byte[] buffer, int offset, int count)
            {
                token.ThrowIfCancellationRequested();
                int num = ParentStream.Read(buffer, offset, count);

                ReadCallback(num);
                return(num);
            }
            public override async Task <int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
            {
                token.ThrowIfCancellationRequested();
                CancellationTokenSource cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(token, cancellationToken);
                int num = await ParentStream.ReadAsync(buffer, offset, count, cancellationTokenSource.Token);

                ReadCallback(num);
                return(num);
            }
            public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
            {
                token.ThrowIfCancellationRequested();
                CancellationTokenSource cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(token, cancellationToken);
                Task result = ParentStream.WriteAsync(buffer, offset, count, cancellationTokenSource.Token);

                WriteCallback(count);
                return(result);
            }
            public override async Task <int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
            {
                _token.ThrowIfCancellationRequested();
                var linked = CancellationTokenSource.CreateLinkedTokenSource(_token, cancellationToken);

                var readCount = await ParentStream.ReadAsync(buffer, offset, count, linked.Token);

                ReadCallback(readCount);
                return(readCount);
            }
            public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
            {
                _token.ThrowIfCancellationRequested();

                var linked = CancellationTokenSource.CreateLinkedTokenSource(_token, cancellationToken);
                var task   = ParentStream.WriteAsync(buffer, offset, count, linked.Token);

                WriteCallback(count);
                return(task);
            }
Esempio n. 7
0
 public override long Seek(long offset, SeekOrigin origin)
 {
     token.ThrowIfCancellationRequested();
     try {
         return(ParentStream.Seek(offset, origin));
     } catch (Exception e) {
         if (exceptionMapper != null)
         {
             exceptionMapper(e);
         }
         throw e;
     }
 }
Esempio n. 8
0
 public override void SetLength(long value)
 {
     token.ThrowIfCancellationRequested();
     try {
         ParentStream.SetLength(value);
     } catch (Exception e) {
         if (exceptionMapper != null)
         {
             exceptionMapper(e);
         }
         throw e;
     }
 }
Esempio n. 9
0
 public override void Write(byte[] buffer, int offset, int count)
 {
     token.ThrowIfCancellationRequested();
     try {
         ParentStream.Write(buffer, offset, count);
     } catch (Exception e) {
         if (exceptionMapper != null)
         {
             exceptionMapper(e);
         }
         throw e;
     }
     WriteCallback(count);
 }
Esempio n. 10
0
 public override int Read(byte[] buffer, int offset, int count)
 {
     token.ThrowIfCancellationRequested();
     try {
         var readCount = ParentStream.Read(buffer, offset, count);
         ReadCallback(readCount);
         return(readCount);
     } catch (Exception e) {
         if (exceptionMapper != null)
         {
             exceptionMapper(e);
         }
         throw e;
     }
 }
Esempio n. 11
0
        public override long Seek(long offset, SeekOrigin origin)
        {
            if (origin == SeekOrigin.Begin || origin == SeekOrigin.End)
            {
                offset += startPosition;
            }

            if (origin == SeekOrigin.End)
            {
                offset += Length;
                origin  = SeekOrigin.Begin;
            }

            ParentStream.Seek(offset, origin);

            return(Position);
        }
Esempio n. 12
0
            public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
            {
                token.ThrowIfCancellationRequested();

                var linked = CancellationTokenSource.CreateLinkedTokenSource(token, cancellationToken);
                var task   = default(Task);

                try {
                    task = ParentStream.WriteAsync(buffer, offset, count, linked.Token);
                } catch (Exception e) {
                    if (exceptionMapper != null)
                    {
                        exceptionMapper(e);
                    }
                    throw e;
                }

                WriteCallback(count);
                return(task);
            }
Esempio n. 13
0
            public override async Task <int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
            {
                token.ThrowIfCancellationRequested();
                var linked = CancellationTokenSource.CreateLinkedTokenSource(token, cancellationToken);

                int readCount;

                try {
                    readCount = await ParentStream.ReadAsync(buffer, offset, count, linked.Token);
                } catch (Exception e) {
                    if (exceptionMapper != null)
                    {
                        exceptionMapper(e);
                    }
                    throw e;
                }

                ReadCallback(readCount);
                return(readCount);
            }
Esempio n. 14
0
 public override void Write(byte[] buffer, int offset, int count)
 {
     ParentStream.Write(buffer, offset, count);
 }
Esempio n. 15
0
 public override void SetLength(long value)
 {
     ParentStream.SetLength(value);
 }
 public override void SetLength(long value)
 {
     token.ThrowIfCancellationRequested();
     ParentStream.SetLength(value);
 }
 public override void Flush()
 {
     ParentStream.Flush();
 }
 public override Task FlushAsync(CancellationToken cancellationToken)
 {
     return(ParentStream.FlushAsync(cancellationToken));
 }
Esempio n. 19
0
 public override int Read(byte[] buffer, int offset, int count)
 {
     return(ParentStream.Read(buffer, offset, count));
 }
 public override long Seek(long offset, SeekOrigin origin)
 {
     token.ThrowIfCancellationRequested();
     return(ParentStream.Seek(offset, origin));
 }
Esempio n. 21
0
 public override long Seek(long offset, SeekOrigin origin)
 {
     return(ParentStream.Seek(offset, origin));
 }
 public override void Write(byte[] buffer, int offset, int count)
 {
     token.ThrowIfCancellationRequested();
     ParentStream.Write(buffer, offset, count);
     WriteCallback(count);
 }
Esempio n. 23
0
        public override int Read(byte[] buffer, int offset, int count)
        {
            count = Math.Min((int)Math.Max(Length - Position, (long)0), count);

            return(ParentStream.Read(buffer, offset, count));
        }