| | 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 System.Collections.Generic; |
| | 7 | |
|
| | 8 | | namespace Azure.Storage.Files.Shares.Models |
| | 9 | | { |
| | 10 | | /// <summary> |
| | 11 | | /// Contains file share range information returned from the ShareFileClient.GetRangeList operations. |
| | 12 | | /// </summary> |
| | 13 | | public class ShareFileRangeInfo |
| | 14 | | { |
| | 15 | | /// <summary> |
| | 16 | | /// Model type expected by the protocol layer. |
| | 17 | | /// </summary> |
| | 18 | | private readonly ShareFileRangeInfoInternal _shareFileRangeInfoInternal; |
| | 19 | |
|
| | 20 | | /// <summary> |
| | 21 | | /// The date/time that the file was last modified. Any operation that modifies the file, including an update of |
| | 22 | | /// </summary> |
| 2 | 23 | | public System.DateTimeOffset LastModified => _shareFileRangeInfoInternal.LastModified; |
| | 24 | |
|
| | 25 | | /// <summary> |
| | 26 | | /// The ETag contains a value which represents the version of the file, in quotes. |
| | 27 | | /// </summary> |
| 6 | 28 | | public ETag ETag => _shareFileRangeInfoInternal.ETag; |
| | 29 | |
|
| | 30 | | /// <summary> |
| | 31 | | /// The size of the file in bytes. |
| | 32 | | /// </summary> |
| 2 | 33 | | public long FileContentLength => _shareFileRangeInfoInternal.FileContentLength; |
| | 34 | |
|
| | 35 | | /// <summary> |
| | 36 | | /// A list of non-overlapping valid ranges, sorted by increasing address range. |
| | 37 | | /// </summary> |
| 0 | 38 | | public IEnumerable<HttpRange> Ranges { get; internal set; } |
| | 39 | |
|
| | 40 | | /// <summary> |
| | 41 | | /// Creates a new PageRangesInfo instance |
| | 42 | | /// </summary> |
| 6 | 43 | | internal ShareFileRangeInfo(ShareFileRangeInfoInternal rangesInfoInternal) |
| | 44 | | { |
| 6 | 45 | | _shareFileRangeInfoInternal = rangesInfoInternal; |
| | 46 | |
|
| | 47 | | // convert from internal Range type to HttpRange |
| 6 | 48 | | var ranges = new List<HttpRange>(); |
| 0 | 49 | | foreach (Range range in rangesInfoInternal.Ranges) |
| | 50 | | { |
| 0 | 51 | | ranges.Add(new HttpRange(range.Start, range.End - range.Start + 1)); |
| | 52 | | } |
| 6 | 53 | | Ranges = ranges; |
| 6 | 54 | | } |
| | 55 | | } |
| | 56 | |
|
| | 57 | | /// <summary> |
| | 58 | | /// ShareModelFactory provides utilities for mocking. |
| | 59 | | /// </summary> |
| | 60 | | public static partial class ShareModelFactory |
| | 61 | | { |
| | 62 | | /// <summary> |
| | 63 | | /// Creates a new ShareFileRangeInfo instance for mocking. |
| | 64 | | /// </summary> |
| | 65 | | public static ShareFileRangeInfo ShareFileRangeInfo( |
| | 66 | | System.DateTimeOffset lastModified, |
| | 67 | | Azure.ETag eTag, |
| | 68 | | long fileContentLength, |
| | 69 | | IEnumerable<HttpRange> ranges) |
| | 70 | | { |
| | 71 | | var shareFileRangeInfo = |
| | 72 | | new ShareFileRangeInfo( |
| | 73 | | new ShareFileRangeInfoInternal() |
| | 74 | | { |
| | 75 | | LastModified = lastModified, |
| | 76 | | ETag = eTag, |
| | 77 | | FileContentLength = fileContentLength |
| | 78 | | } |
| | 79 | | ) |
| | 80 | | { |
| | 81 | | Ranges = ranges |
| | 82 | | }; |
| | 83 | | return shareFileRangeInfo; |
| | 84 | | } |
| | 85 | | } |
| | 86 | | } |