Exemple #1
0
        public IEnumerable <CloudBlob> Translate(IExpression expression, CloudBlobClient blobClient, MediaFolder mediaFolder)
        {
            this.Visite(expression);

            if (!string.IsNullOrEmpty(fileName))
            {
                var blob = blobClient.GetBlockBlobReference(mediaFolder.GetMediaFolderItemPath(fileName));
                if (!blob.Exists())
                {
                    return(new CloudBlob[] { });
                }
                blob.FetchAttributes();
                return(new[] { blob });
            }
            else
            {
                var maxResult = 1000;
                if (Take.HasValue)
                {
                    maxResult = Take.Value;
                }
                var take = maxResult;

                var skip = 0;
                if (Skip.HasValue)
                {
                    skip       = Skip.Value;
                    maxResult += skip;
                }
                var blobPrefix = mediaFolder.GetMediaFolderItemPath(prefix);

                if (string.IsNullOrEmpty(prefix))
                {
                    blobPrefix += "/";
                }

                return(blobClient.ListBlobsWithPrefixSegmented(blobPrefix, maxResult, null, new BlobRequestOptions()
                {
                    BlobListingDetails = Microsoft.WindowsAzure.StorageClient.BlobListingDetails.Metadata, UseFlatBlobListing = false
                })
                       .Results.Skip(skip).Select(it => it as CloudBlob).Take(take));
            }
        }