예제 #1
0
        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));
        }
        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);
        }
            public Task <IValueProvider> BindAsync(IStorageBlobContainer container, ValueBindingContext context)
            {
                if (container == null)
                {
                    throw new ArgumentNullException("container");
                }

                BlobValueBindingContext blobValueBindingContext = (BlobValueBindingContext)context;
                CloudBlobDirectory      directory = container.SdkObject.GetDirectoryReference(blobValueBindingContext.Path.BlobName);

                return(Task.FromResult <IValueProvider>(new ValueProvider(directory)));
            }
            public async Task <IValueProvider> BindAsync(IStorageBlobContainer container, ValueBindingContext context)
            {
                BlobValueBindingContext containerBindingContext = (BlobValueBindingContext)context;

                // Query the blob container using the blob prefix (if specified)
                // Note that we're explicitly using useFlatBlobListing=true to collapse
                // sub directories. If users want to bind to a sub directory, they can
                // bind to CloudBlobDirectory.
                string prefix = containerBindingContext.Path.BlobName;
                IEnumerable <IStorageListBlobItem> blobItems = await container.ListBlobsAsync(prefix, true, context.CancellationToken);

                // create an IEnumerable<T> of the correct type, performing any
                // required conversions on the blobs
                Type  elementType = _parameter.ParameterType.GenericTypeArguments[0];
                IList list        = await ConvertBlobs(elementType, blobItems);

                string invokeString = containerBindingContext.Path.ToString();

                return(new ValueProvider(list, _parameter.ParameterType, invokeString));
            }