| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.IO; |
| | 6 | |
|
| | 7 | | namespace Azure.Storage |
| | 8 | | { |
| | 9 | | internal static class StorageProgressExtensions |
| | 10 | | { |
| | 11 | | public static Stream WithProgress(this Stream stream, IProgress<long> progressHandler) |
| | 12 | | { |
| 332 | 13 | | if (progressHandler != null && stream != null) |
| | 14 | | { |
| 4 | 15 | | if (progressHandler is AggregatingProgressIncrementer handler) |
| | 16 | | { |
| 0 | 17 | | return handler.CreateProgressIncrementingStream(stream); |
| | 18 | | } |
| | 19 | | else |
| | 20 | | { |
| 4 | 21 | | return (new AggregatingProgressIncrementer(progressHandler)) |
| 4 | 22 | | .CreateProgressIncrementingStream(stream); |
| | 23 | | } |
| | 24 | | } |
| | 25 | | else |
| | 26 | | { |
| 328 | 27 | | return stream; |
| | 28 | | } |
| | 29 | | } |
| | 30 | | } |
| | 31 | | } |