Exemple #1
0
        public static async Task <IReadOnlyCollection <Blob> > ToBlobsAsync(PagedAsyncEnumerable <Objects, Object> pae, ListOptions options)
        {
            var result = new List <Blob>();

#pragma warning disable IDE0008 // Use explicit type (async enumerator conflict)
            await using (var enumerator = pae.GetAsyncEnumerator())
#pragma warning restore IDE0008 // Use explicit type
            {
                while (await enumerator.MoveNextAsync().ConfigureAwait(false))
                {
                    Object go = enumerator.Current;

                    Blob blob = ToBlob(go);

                    if (options.FilePrefix != null && !blob.Name.StartsWith(options.FilePrefix))
                    {
                        continue;
                    }

                    if (options.BrowseFilter != null && !options.BrowseFilter(blob))
                    {
                        continue;
                    }

                    result.Add(blob);

                    if (options.MaxResults != null && result.Count >= options.MaxResults.Value)
                    {
                        break;
                    }
                }
            }

            return(result);
        }