| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Collections.Generic; |
| | 6 | | using System.ComponentModel; |
| | 7 | | using System.Linq; |
| | 8 | | using System.Threading; |
| | 9 | | using System.Threading.Tasks; |
| | 10 | |
|
| | 11 | | #pragma warning disable SA1402 // File may only contain a single type |
| | 12 | |
|
| | 13 | | namespace Azure.Storage.Blobs.Models |
| | 14 | | { |
| | 15 | | /// <summary> |
| | 16 | | /// Either a <see cref="Prefix"/> or <see cref="Blob"/> returned from |
| | 17 | | /// <see cref="BlobContainerClient.GetBlobsByHierarchyAsync"/>. |
| | 18 | | /// </summary> |
| | 19 | | public class BlobHierarchyItem |
| | 20 | | { |
| | 21 | | /// <summary> |
| | 22 | | /// Gets a prefix, relative to the delimiter used to get the blobs. |
| | 23 | | /// </summary> |
| 21348 | 24 | | public string Prefix { get; internal set; } |
| | 25 | |
|
| | 26 | | /// <summary> |
| | 27 | | /// Gets a blob. |
| | 28 | | /// </summary> |
| 21256 | 29 | | public BlobItem Blob { get; internal set; } |
| | 30 | |
|
| | 31 | | /// <summary> |
| | 32 | | /// Gets a value indicating if this item represents a <see cref="Prefix"/>. |
| | 33 | | /// </summary> |
| 10316 | 34 | | public bool IsPrefix => Prefix != null; |
| | 35 | |
|
| | 36 | | /// <summary> |
| | 37 | | /// Gets a value indicating if this item represents a <see cref="Blob"/>. |
| | 38 | | /// </summary> |
| 20 | 39 | | public bool IsBlob => Blob != null; |
| | 40 | |
|
| | 41 | | /// <summary> |
| | 42 | | /// Initialies a new instance of the BlobHierarchyItem class. |
| | 43 | | /// </summary> |
| | 44 | | /// <param name="prefix"> |
| | 45 | | /// A prefix, relative to the delimiter used to get the blobs. |
| | 46 | | /// </param> |
| | 47 | | /// <param name="blob"> |
| | 48 | | /// A blob. |
| | 49 | | /// </param> |
| 10648 | 50 | | internal BlobHierarchyItem(string prefix, BlobItem blob) |
| | 51 | | { |
| 10648 | 52 | | Prefix = prefix; |
| 10648 | 53 | | Blob = blob; |
| 10648 | 54 | | } |
| | 55 | | } |
| | 56 | |
|
| | 57 | | /// <summary> |
| | 58 | | /// BlobsModelFactory provides utilities for mocking. |
| | 59 | | /// </summary> |
| | 60 | | public static partial class BlobsModelFactory |
| | 61 | | { |
| | 62 | | /// <summary> |
| | 63 | | /// Creates a new BlobHierarchyItem instance for mocking. |
| | 64 | | /// </summary> |
| | 65 | | public static BlobHierarchyItem BlobHierarchyItem( |
| | 66 | | string prefix, |
| | 67 | | BlobItem blob) => |
| | 68 | | new BlobHierarchyItem(prefix, blob); |
| | 69 | | } |
| | 70 | | } |