| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System.Collections.Generic; |
| | 5 | | using System.Linq; |
| | 6 | | using System.Threading; |
| | 7 | | using System.Threading.Tasks; |
| | 8 | | using Azure.Core.Pipeline; |
| | 9 | |
|
| | 10 | | namespace Azure.Storage.Files.Shares.Models |
| | 11 | | { |
| | 12 | | internal class GetFilesAndDirectoriesAsyncCollection : StorageCollectionEnumerator<ShareFileItem> |
| | 13 | | { |
| | 14 | | private readonly ShareDirectoryClient _client; |
| | 15 | | private readonly string _prefix; |
| | 16 | |
|
| 54 | 17 | | public GetFilesAndDirectoriesAsyncCollection( |
| 54 | 18 | | ShareDirectoryClient client, |
| 54 | 19 | | string prefix) |
| | 20 | | { |
| 54 | 21 | | _client = client; |
| 54 | 22 | | _prefix = prefix; |
| 54 | 23 | | } |
| | 24 | |
|
| | 25 | | public override async ValueTask<Page<ShareFileItem>> GetNextPageAsync( |
| | 26 | | string continuationToken, |
| | 27 | | int? pageSizeHint, |
| | 28 | | bool async, |
| | 29 | | CancellationToken cancellationToken) |
| | 30 | | { |
| 54 | 31 | | Response<FilesAndDirectoriesSegment> response = await _client.GetFilesAndDirectoriesInternal( |
| 54 | 32 | | continuationToken, |
| 54 | 33 | | _prefix, |
| 54 | 34 | | pageSizeHint, |
| 54 | 35 | | async, |
| 54 | 36 | | cancellationToken).ConfigureAwait(false); |
| | 37 | |
|
| 52 | 38 | | var items = new List<ShareFileItem>(); |
| 94 | 39 | | items.AddRange(response.Value.DirectoryItems.Select(d => new ShareFileItem(true, d.Name))); |
| 90 | 40 | | items.AddRange(response.Value.FileItems.Select(f => new ShareFileItem(false, f.Name, f.Properties?.ContentLe |
| 52 | 41 | | return Page<ShareFileItem>.FromValues( |
| 52 | 42 | | items.ToArray(), |
| 52 | 43 | | response.Value.NextMarker, |
| 52 | 44 | | response.GetRawResponse()); |
| 52 | 45 | | } |
| | 46 | | } |
| | 47 | | } |