| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System.IO; |
| | 5 | | using System.Threading; |
| | 6 | | using System.Threading.Tasks; |
| | 7 | |
|
| | 8 | | #pragma warning disable SA1402 // File may only contain a single type |
| | 9 | |
|
| | 10 | | namespace Azure.Storage |
| | 11 | | { |
| | 12 | | internal class NonDisposingStream : Stream |
| | 13 | | { |
| | 14 | | private readonly Stream _innerStream; |
| | 15 | |
|
| 10504 | 16 | | public NonDisposingStream(Stream innerStream) => _innerStream = innerStream; |
| | 17 | |
|
| 16 | 18 | | public override bool CanRead => _innerStream.CanRead; |
| | 19 | |
|
| 15772 | 20 | | public override bool CanSeek => _innerStream.CanSeek; |
| | 21 | |
|
| 0 | 22 | | public override bool CanWrite => _innerStream.CanWrite; |
| | 23 | |
|
| 3116 | 24 | | public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken) => _in |
| | 25 | |
|
| 16324 | 26 | | public override long Length => _innerStream.Length; |
| | 27 | |
|
| 0 | 28 | | public override long Position { get => _innerStream.Position; set => _innerStream.Position = value; } |
| | 29 | |
|
| 0 | 30 | | public override void Flush() => _innerStream.Flush(); |
| | 31 | |
|
| 0 | 32 | | public override Task FlushAsync(CancellationToken cancellationToken) => _innerStream.FlushAsync(cancellationToke |
| | 33 | |
|
| 16824 | 34 | | public override int Read(byte[] buffer, int offset, int count) => _innerStream.Read(buffer, offset, count); |
| | 35 | |
|
| 96 | 36 | | public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) = |
| | 37 | |
|
| 10508 | 38 | | public override long Seek(long offset, SeekOrigin origin) => _innerStream.Seek(offset, origin); |
| | 39 | |
|
| 0 | 40 | | public override void SetLength(long value) => _innerStream.SetLength(value); |
| | 41 | |
|
| 0 | 42 | | public override void Write(byte[] buffer, int offset, int count) => _innerStream.Write(buffer, offset, count); |
| | 43 | |
|
| 0 | 44 | | public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) => _i |
| | 45 | |
|
| 0 | 46 | | protected override void Dispose(bool disposing) { /* swallow disposal */ } |
| | 47 | | } |
| | 48 | |
|
| | 49 | | internal static partial class StreamExtensions |
| | 50 | | { |
| | 51 | | public static Stream WithNoDispose(this Stream stream) => stream is NonDisposingStream ? stream : new NonDisposi |
| | 52 | | } |
| | 53 | | } |