示例#1
0
            public IEnumerable <IStorageBlob> ListBlobs(MemoryBlobStore store, IStorageBlobContainer parent,
                                                        BlobListingDetails blobListingDetails)
            {
                if (blobListingDetails != BlobListingDetails.None && blobListingDetails != BlobListingDetails.Metadata)
                {
                    throw new NotImplementedException();
                }
                List <IStorageBlob> results = new List <IStorageBlob>();

                foreach (KeyValuePair <string, Blob> item in _items)
                {
                    string blobName = item.Key;

                    // Etag  and LastModifiedTime is always passed in listBlobs
                    FakeStorageBlobProperties properties = new FakeStorageBlobProperties()
                    {
                        ETag         = item.Value.ETag,
                        LastModified = item.Value.LastModified,
                    };

                    IStorageBlob blob = new FakeStorageBlockBlob(store, blobName, parent, properties);
                    if ((blobListingDetails | BlobListingDetails.Metadata) == BlobListingDetails.Metadata)
                    {
                        Blob storeBlob = item.Value;
                        IReadOnlyDictionary <string, string> storeMetadata = storeBlob.Metadata;

                        foreach (KeyValuePair <string, string> pair in storeMetadata)
                        {
                            blob.Metadata.Add(pair.Key, pair.Value);
                        }
                    }

                    results.Add(blob);
                }

                return(results);
            }
示例#2
0
            public ICloudBlob GetBlobReferenceFromServer(MemoryBlobStore store, CloudBlobContainer parent, string blobName)
            {
                if (!_items.ContainsKey(blobName))
                {
                    throw StorageExceptionFactory.Create(404);
                }

                Blob blob = _items[blobName];

                switch (blob.BlobType)
                {
                case StorageBlobType.BlockBlob:
                    return(new FakeStorageBlockBlob(store, blobName, parent));

                case StorageBlobType.PageBlob:
                    return(new FakeStoragePageBlob(store, blobName, parent));

                case StorageBlobType.AppendBlob:
                    return(new FakeStorageAppendBlob(store, blobName, parent));

                default:
                    throw new InvalidOperationException(string.Format("Type '{0}' is not supported.", blob.BlobType));
                }
            }