public ICloudBlob GetBlobReferenceFromServer(MemoryBlobStore store, FakeStorageBlobContainer parent, string blobName) { if (!_items.ContainsKey(blobName)) { throw StorageExceptionFactory.Create(404); } Blob blob = _items[blobName]; if (blob._hook != null) { return(blob._hook); } FakeStorageBlobProperties properties = new FakeStorageBlobProperties() { ETag = blob.ETag, LastModified = blob.LastModified, }; switch (blob.BlobType) { case BlobType.BlockBlob: return(new FakeStorageBlockBlob(blobName, parent, properties)); case BlobType.PageBlob: return(new FakeStoragePageBlob(blobName, parent, properties)); case BlobType.AppendBlob: return(new FakeStorageAppendBlob(blobName, parent, properties)); default: throw new InvalidOperationException(string.Format("Type '{0}' is not supported.", blob.BlobType)); } }
public FakeStorageBlobClient(FakeAccount account) : base(FakeUri) { _store = account._blobStore; this.SetInternalProperty(nameof(Credentials), account._creds); }
public FakeStorageAppendBlob(string blobName, FakeStorageBlobContainer parent, FakeStorageBlobProperties properties = null) : base(parent.GetBlobUri(blobName)) { _store = parent._store; _blobName = blobName; _parent = parent; _containerName = parent.Name; _metadata = new Dictionary <string, string>(); if (properties != null) { _properties = properties; ApplyProperties(); } else { _properties = new FakeStorageBlobProperties(); } // currentBlob.Properties.LastModified.Value.UtcDateTime; // CloudBlob.Properties { return this.attributes.Properties } // where attributes is internal BlobAttributes class. // return BlobProperties this.SetInternalProperty(nameof(ServiceClient), parent._client); }
public FakeStorageBlobContainer(FakeStorageBlobClient client, string containerName) : base(client.GetContainerUri(containerName)) { if (string.IsNullOrWhiteSpace(this.Name)) { throw new ArgumentException(nameof(containerName)); } _store = client._store; _client = client; this.SetInternalProperty(nameof(ServiceClient), client); }
public FakeStoragePageBlob(string blobName, FakeStorageBlobContainer parent, FakeStorageBlobProperties properties = null) : base(parent.GetBlobUri(blobName)) { _store = parent._store; _blobName = blobName; _parent = parent; _containerName = parent.Name; _metadata = new Dictionary <string, string>(); if (properties != null) { _properties = properties; ApplyProperties(); } else { _properties = new FakeStorageBlobProperties(); } this.SetInternalProperty(nameof(ServiceClient), parent._client); }
public IEnumerable <ICloudBlob> ListBlobs(MemoryBlobStore store, FakeStorageBlobContainer parent, BlobListingDetails blobListingDetails) { if (blobListingDetails != BlobListingDetails.None && blobListingDetails != BlobListingDetails.Metadata) { throw new NotImplementedException(); } List <ICloudBlob> results = new List <ICloudBlob>(); 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, }; ICloudBlob blob = new FakeStorageBlockBlob(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); }