| | 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 | | { |
| 5252 | 13 | | if (progressHandler != null && stream != null) |
| | 14 | | { |
| 16 | 15 | | if (progressHandler is AggregatingProgressIncrementer handler) |
| | 16 | | { |
| 0 | 17 | | return handler.CreateProgressIncrementingStream(stream); |
| | 18 | | } |
| | 19 | | else |
| | 20 | | { |
| 16 | 21 | | return (new AggregatingProgressIncrementer(progressHandler)) |
| 16 | 22 | | .CreateProgressIncrementingStream(stream); |
| | 23 | | } |
| | 24 | | } |
| | 25 | | else |
| | 26 | | { |
| 5236 | 27 | | return stream; |
| | 28 | | } |
| | 29 | | } |
| | 30 | | } |
| | 31 | | } |