public async Task <IValueProvider> BindAsync(BindingContext context)
        {
            BlobPath boundPath = _path.Bind(context.BindingData);
            IStorageBlobContainer container        = _client.GetContainerReference(boundPath.ContainerName);
            ValueBindingContext   containerContext = new BlobValueBindingContext(boundPath, context.ValueContext);

            return(await BindBlobContainerAsync(container, containerContext));
        }
Beispiel #2
0
        public async Task <IValueProvider> BindAsync(BindingContext context)
        {
            BlobPath boundPath = _path.Bind(context.BindingData);
            IStorageBlobContainer container = _client.GetContainerReference(boundPath.ContainerName);

            if (_argumentBinding.Access != FileAccess.Read)
            {
                await container.CreateIfNotExistsAsync(context.CancellationToken);
            }

            Type         argumentType = _argumentBinding.ValueType;
            string       blobName     = boundPath.BlobName;
            IStorageBlob blob         = await container.GetBlobReferenceForArgumentTypeAsync(blobName, argumentType, context.CancellationToken);

            return(await BindBlobAsync(blob, context.ValueContext));
        }
        public async Task <IStorageBlob> ConvertAsync(string input, CancellationToken cancellationToken)
        {
            BlobPath path;

            // For convenience, treat an an empty string as a request for the default value.
            if (String.IsNullOrEmpty(input) && _defaultPath.IsBound)
            {
                path = _defaultPath.Bind(null);
            }
            else
            {
                path = BlobPath.ParseAndValidate(input);
            }

            IStorageBlobContainer container = _client.GetContainerReference(path.ContainerName);
            await container.CreateIfNotExistsAsync(cancellationToken);

            return(await container.GetBlobReferenceForArgumentTypeAsync(path.BlobName, _argumentType,
                                                                        cancellationToken));
        }