| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | #pragma warning disable SA1402 // File may only contain a single type |
| | 5 | |
|
| | 6 | | using Azure.Storage.Files.Shares.Models; |
| | 7 | |
|
| | 8 | | namespace Azure.Storage.Files.Shares.Models |
| | 9 | | { |
| | 10 | | /// <summary> |
| | 11 | | /// The result of a force close handle or force close all handles operation. |
| | 12 | | /// </summary> |
| | 13 | | public class CloseHandlesResult |
| | 14 | | { |
| | 15 | | /// <summary> |
| | 16 | | /// The number of file handles that were closed. |
| | 17 | | /// </summary> |
| | 18 | | public int ClosedHandlesCount { get; internal set; } |
| | 19 | |
|
| | 20 | | /// <summary> |
| | 21 | | /// The number of file handles that fialed to close. |
| | 22 | | /// </summary> |
| | 23 | | public int FailedHandlesCount { get; internal set; } |
| | 24 | |
|
| | 25 | | /// <summary> |
| | 26 | | /// Prevent direct instantiation of ClosedHandlesInfo instances. |
| | 27 | | /// You can use FileModelFactory.ClosedHandlesInfo instead. |
| | 28 | | /// </summary> |
| | 29 | | internal CloseHandlesResult() { } |
| | 30 | | } |
| | 31 | |
|
| | 32 | | /// <summary> |
| | 33 | | /// FilesModelFactory provides utilities for mocking. |
| | 34 | | /// </summary> |
| | 35 | | public static partial class FileModelFactory |
| | 36 | | { |
| | 37 | | /// <summary> |
| | 38 | | /// Creates a new ClosedHandlesInfo instance for mocking. |
| | 39 | | /// </summary> |
| | 40 | | public static CloseHandlesResult ClosedHandlesInfo( |
| | 41 | | int closedHandlesCount) |
| 0 | 42 | | => ClosedHandlesInfo( |
| 0 | 43 | | closedHandlesCount: closedHandlesCount, |
| 0 | 44 | | failedHandlesCount: 0); |
| | 45 | |
|
| | 46 | | /// <summary> |
| | 47 | | /// Creates a new ClosedHandlesInfo instance for mocking. |
| | 48 | | /// </summary> |
| | 49 | | public static CloseHandlesResult ClosedHandlesInfo( |
| | 50 | | int closedHandlesCount, |
| | 51 | | int failedHandlesCount) |
| 0 | 52 | | => new CloseHandlesResult() |
| 0 | 53 | | { |
| 0 | 54 | | ClosedHandlesCount = closedHandlesCount, |
| 0 | 55 | | FailedHandlesCount = failedHandlesCount |
| 0 | 56 | | }; |
| | 57 | | } |
| | 58 | | } |
| | 59 | |
|
| | 60 | | namespace Azure.Storage.Files.Shares |
| | 61 | | { |
| | 62 | | internal static partial class ShareExtensions |
| | 63 | | { |
| | 64 | | internal static CloseHandlesResult ToCloseHandlesResult(this Response<StorageClosedHandlesSegment> storageClosed |
| | 65 | | { |
| | 66 | | if (storageClosedHandlesSegment == null || storageClosedHandlesSegment.Value == null) |
| | 67 | | { |
| | 68 | | return null; |
| | 69 | | } |
| | 70 | |
|
| | 71 | | return new CloseHandlesResult |
| | 72 | | { |
| | 73 | | ClosedHandlesCount = storageClosedHandlesSegment.Value.NumberOfHandlesClosed, |
| | 74 | | FailedHandlesCount = storageClosedHandlesSegment.Value.NumberOfHandlesFailedToClose |
| | 75 | | }; |
| | 76 | | } |
| | 77 | | } |
| | 78 | | } |