Esempio n. 1
0
        public Task <IBinding> TryCreateAsync(BindingProviderContext context)
        {
            ParameterInfo       parameter           = context.Parameter;
            ServiceBusAttribute serviceBusAttribute = parameter.GetCustomAttribute <ServiceBusAttribute>(inherit: false);

            if (serviceBusAttribute == null)
            {
                return(Task.FromResult <IBinding>(null));
            }

            string queueOrTopicName      = Resolve(serviceBusAttribute.QueueOrTopicName);
            IBindableServiceBusPath path = BindableServiceBusPath.Create(queueOrTopicName);

            path.ValidateContractCompatibility(context.BindingDataContract);

            IArgumentBinding <ServiceBusEntity> argumentBinding = _innerProvider.TryCreate(parameter);

            if (argumentBinding == null)
            {
                throw new InvalidOperationException("Can't bind ServiceBus to type '" + parameter.ParameterType + "'.");
            }

            string            connectionString = _accountProvider.ConnectionString;
            ServiceBusAccount account          = ServiceBusAccount.CreateFromConnectionString(connectionString);

            IBinding binding = new ServiceBusBinding(parameter.Name, argumentBinding, account, path);

            return(Task.FromResult(binding));
        }
        public Task <IBinding> TryCreateAsync(BindingProviderContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            ParameterInfo  parameter = context.Parameter;
            RedisAttribute attribute = parameter.GetCustomAttribute <RedisAttribute>(inherit: false);

            if (attribute == null)
            {
                return(Task.FromResult <IBinding>(null));
            }

            IArgumentBinding <RedisEntity> argumentBinding = Provider.TryCreate(parameter);

            if (argumentBinding == null)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture,
                                                                  "Can't bind to type '{0}'.", parameter.ParameterType));
            }

            var account = RedisAccount.CreateDbFromConnectionString(_config.ConnectionString);

            IBinding binding = new RedisBinding(parameter.Name, argumentBinding, account, attribute, context, _trace);

            return(Task.FromResult(binding));
        }
        public async Task <IBinding> TryCreateAsync(BindingProviderContext context)
        {
            ParameterInfo  parameter      = context.Parameter;
            QueueAttribute queueAttribute = parameter.GetCustomAttribute <QueueAttribute>(inherit: false);

            if (queueAttribute == null)
            {
                return(null);
            }

            string             queueName = Resolve(queueAttribute.QueueName);
            IBindableQueuePath path      = BindableQueuePath.Create(queueName);

            path.ValidateContractCompatibility(context.BindingDataContract);

            IArgumentBinding <IStorageQueue> argumentBinding = _innerProvider.TryCreate(parameter);

            if (argumentBinding == null)
            {
                throw new InvalidOperationException("Can't bind Queue to type '" + parameter.ParameterType + "'.");
            }

            IStorageAccount account = await _accountProvider.GetStorageAccountAsync(context.Parameter, context.CancellationToken);

            StorageClientFactoryContext clientFactoryContext = new StorageClientFactoryContext
            {
                Parameter = parameter
            };
            IStorageQueueClient client  = account.CreateQueueClient(clientFactoryContext);
            IBinding            binding = new QueueBinding(parameter.Name, argumentBinding, client, path);

            return(binding);
        }
        public async Task <ITriggerBinding> TryCreateAsync(TriggerBindingProviderContext context)
        {
            ParameterInfo        parameter            = context.Parameter;
            BlobTriggerAttribute blobTriggerAttribute = parameter.GetCustomAttribute <BlobTriggerAttribute>(inherit: false);

            if (blobTriggerAttribute == null)
            {
                return(null);
            }

            string          resolvedCombinedPath = Resolve(blobTriggerAttribute.BlobPath);
            IBlobPathSource path = BlobPathSource.Create(resolvedCombinedPath);

            IArgumentBinding <IStorageBlob> argumentBinding = _provider.TryCreate(parameter, access: null);

            if (argumentBinding == null)
            {
                throw new InvalidOperationException("Can't bind BlobTrigger to type '" + parameter.ParameterType + "'.");
            }

            IStorageAccount hostAccount = await _accountProvider.GetStorageAccountAsync(context.CancellationToken);

            IStorageAccount dataAccount = await _accountProvider.GetStorageAccountAsync(context.Parameter, context.CancellationToken, _nameResolver);

            ITriggerBinding binding = new BlobTriggerBinding(parameter, argumentBinding, hostAccount, dataAccount, path,
                                                             _hostIdProvider, _queueConfiguration, _backgroundExceptionDispatcher, _blobWrittenWatcherSetter,
                                                             _messageEnqueuedWatcherSetter, _sharedContextProvider, _trace);

            return(binding);
        }
        public Task <IBinding> TryCreateAsync(BindingProviderContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            ParameterInfo parameter = context.Parameter;
            var           attribute = TypeUtility.GetResolvedAttribute <ServiceBusAttribute>(parameter);

            if (attribute == null)
            {
                return(Task.FromResult <IBinding>(null));
            }

            string queueOrTopicName      = Resolve(attribute.QueueOrTopicName);
            IBindableServiceBusPath path = BindableServiceBusPath.Create(queueOrTopicName);

            ValidateContractCompatibility(path, context.BindingDataContract);

            IArgumentBinding <ServiceBusEntity> argumentBinding = InnerProvider.TryCreate(parameter);

            if (argumentBinding == null)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, "Can't bind ServiceBus to type '{0}'.", parameter.ParameterType));
            }

            attribute.Connection = Resolve(attribute.Connection);
            ServiceBusAccount account = new ServiceBusAccount(_options, _configuration, attribute);

            IBinding binding = new ServiceBusBinding(parameter.Name, argumentBinding, account, _options, path, attribute, _messagingProvider);

            return(Task.FromResult <IBinding>(binding));
        }
        public async Task <ITriggerBinding> TryCreateAsync(TriggerBindingProviderContext context)
        {
            ParameterInfo        parameter            = context.Parameter;
            BlobTriggerAttribute blobTriggerAttribute = parameter.GetCustomAttribute <BlobTriggerAttribute>(inherit: false);

            if (blobTriggerAttribute == null)
            {
                return(null);
            }

            string          resolvedCombinedPath = Resolve(blobTriggerAttribute.BlobPath);
            IBlobPathSource path = BlobPathSource.Create(resolvedCombinedPath);

            IArgumentBinding <IStorageBlob> argumentBinding = _provider.TryCreate(parameter, access: null);

            if (argumentBinding == null)
            {
                throw new InvalidOperationException("Can't bind BlobTrigger to type '" + parameter.ParameterType + "'.");
            }

            IStorageAccount hostAccount = await _accountProvider.GetStorageAccountAsync(context.CancellationToken);

            IStorageAccount dataAccount = await _accountProvider.GetStorageAccountAsync(context.Parameter, context.CancellationToken, _nameResolver);

            // premium does not support blob logs, so disallow for blob triggers
            dataAccount.AssertTypeOneOf(StorageAccountType.GeneralPurpose, StorageAccountType.BlobOnly);

            ITriggerBinding binding = new BlobTriggerBinding(parameter, argumentBinding, hostAccount, dataAccount, path,
                                                             _hostIdProvider, _queueConfiguration, _exceptionHandler, _blobWrittenWatcherSetter,
                                                             _messageEnqueuedWatcherSetter, _sharedContextProvider, _singletonManager, _trace);

            return(binding);
        }
 public BlobContainerBinding(string parameterName, IArgumentBinding<IStorageBlobContainer> argumentBinding, IStorageBlobClient client,
     IBindableBlobPath path)
 {
     _parameterName = parameterName;
     _argumentBinding = argumentBinding;
     _client = client;
     _path = path;
 }
Esempio n. 8
0
 public BlobContainerBinding(string parameterName, IArgumentBinding <IStorageBlobContainer> argumentBinding, IStorageBlobClient client,
                             IBindableBlobPath path)
 {
     _parameterName   = parameterName;
     _argumentBinding = argumentBinding;
     _client          = client;
     _path            = path;
 }
Esempio n. 9
0
        public async Task <IBinding> TryCreateAsync(BindingProviderContext context)
        {
            ParameterInfo  parameter      = context.Parameter;
            TableAttribute tableAttribute = parameter.GetCustomAttribute <TableAttribute>(inherit: false);

            if (tableAttribute == null)
            {
                return(null);
            }

            string          tableName = Resolve(tableAttribute.TableName);
            IStorageAccount account   = await _accountProvider.GetStorageAccountAsync(context.Parameter, context.CancellationToken, _nameResolver);

            // requires storage account with table support
            account.AssertTypeOneOf(StorageAccountType.GeneralPurpose);

            StorageClientFactoryContext clientFactoryContext = new StorageClientFactoryContext
            {
                Parameter = context.Parameter
            };
            IStorageTableClient client = account.CreateTableClient(clientFactoryContext);

            bool     bindsToEntireTable = tableAttribute.RowKey == null;
            IBinding binding;

            if (bindsToEntireTable)
            {
                IBindableTablePath path = BindableTablePath.Create(tableName);
                path.ValidateContractCompatibility(context.BindingDataContract);

                IStorageTableArgumentBinding argumentBinding = _tableBindingProvider.TryCreate(parameter);

                if (argumentBinding == null)
                {
                    throw new InvalidOperationException("Can't bind Table to type '" + parameter.ParameterType + "'.");
                }

                binding = new TableBinding(parameter.Name, argumentBinding, client, path);
            }
            else
            {
                string partitionKey           = Resolve(tableAttribute.PartitionKey);
                string rowKey                 = Resolve(tableAttribute.RowKey);
                IBindableTableEntityPath path = BindableTableEntityPath.Create(tableName, partitionKey, rowKey);
                path.ValidateContractCompatibility(context.BindingDataContract);

                IArgumentBinding <TableEntityContext> argumentBinding = _entityBindingProvider.TryCreate(parameter);

                if (argumentBinding == null)
                {
                    throw new InvalidOperationException("Can't bind Table entity to type '" + parameter.ParameterType + "'.");
                }

                binding = new TableEntityBinding(parameter.Name, argumentBinding, client, path);
            }

            return(binding);
        }
Esempio n. 10
0
        public void Create_ReturnsBinding_IfContainsResolvedGenericParameter()
        {
            var converterMock = CreateConverterMock(typeof(GenericClass <SimpleTableEntity>));
            // Act
            IArgumentBinding <TableEntityContext> binding = TableAttributeBindingProvider.TryCreatePocoBinding(_parameters[1], converterMock.Object);

            // Assert
            Assert.NotNull(binding);
        }
Esempio n. 11
0
        public void Create_ReturnsBinding_IfImplementsITableEntity()
        {
            var converterMock = CreateConverterMock(typeof(SimpleITableEntity));
            // Act
            IArgumentBinding <TableEntityContext> binding = TableAttributeBindingProvider.TryCreatePocoBinding(_parameters[2], converterMock.Object);

            // Assert
            Assert.NotNull(binding);
        }
 public TableEntityBinding(string parameterName, IArgumentBinding <TableEntityContext> argumentBinding,
                           IStorageTableClient client, IBindableTableEntityPath path)
 {
     _parameterName   = parameterName;
     _argumentBinding = argumentBinding;
     _client          = client;
     _accountName     = TableClient.GetAccountName(client);
     _path            = path;
     _converter       = CreateConverter(client, path);
 }
Esempio n. 13
0
 public ServiceBusBinding(string parameterName, IArgumentBinding <ServiceBusEntity> argumentBinding, ServiceBusAccount account, IBindableServiceBusPath path, AccessRights accessRights)
 {
     _parameterName   = parameterName;
     _argumentBinding = argumentBinding;
     _account         = account;
     _namespaceName   = ServiceBusClient.GetNamespaceName(account);
     _path            = path;
     _accessRights    = accessRights;
     _converter       = CreateConverter(account, path, accessRights);
 }
Esempio n. 14
0
 public ServiceBusBinding(string parameterName, IArgumentBinding <ServiceBusEntity> argumentBinding, ServiceBusAccount account, IBindableServiceBusPath path, ServiceBusAttribute attr, MessagingProvider messagingProvider)
 {
     _parameterName     = parameterName;
     _argumentBinding   = argumentBinding;
     _account           = account;
     _path              = path;
     _entityType        = attr.EntityType;
     _messagingProvider = messagingProvider;
     _converter         = new OutputConverter <string>(new StringToServiceBusEntityConverter(account, _path, _entityType, _messagingProvider));
 }
 public TableEntityBinding(string parameterName, IArgumentBinding<TableEntityContext> argumentBinding,
     IStorageTableClient client, IBindableTableEntityPath path)
 {
     _parameterName = parameterName;
     _argumentBinding = argumentBinding;
     _client = client;
     _accountName = TableClient.GetAccountName(client);
     _path = path;
     _converter = CreateConverter(client, path);
 }
 public ServiceBusBinding(string parameterName, IArgumentBinding<ServiceBusEntity> argumentBinding, ServiceBusAccount account, IBindableServiceBusPath path, AccessRights accessRights)
 {
     _parameterName = parameterName;
     _argumentBinding = argumentBinding;
     _account = account;
     _namespaceName = ServiceBusClient.GetNamespaceName(account);
     _path = path;
     _accessRights = accessRights;
     _converter = CreateConverter(account, path, accessRights);
 }
Esempio n. 17
0
 public QueueBinding(string parameterName, IArgumentBinding<IStorageQueue> argumentBinding,
     IStorageQueueClient client, IBindableQueuePath path)
 {
     _parameterName = parameterName;
     _argumentBinding = argumentBinding;
     _client = client;
     _accountName = QueueClient.GetAccountName(client);
     _path = path;
     _converter = CreateConverter(client, path);
 }
Esempio n. 18
0
 public QueueBinding(string parameterName, IArgumentBinding <IStorageQueue> argumentBinding,
                     IStorageQueueClient client, IBindableQueuePath path)
 {
     _parameterName   = parameterName;
     _argumentBinding = argumentBinding;
     _client          = client;
     _accountName     = QueueClient.GetAccountName(client);
     _path            = path;
     _converter       = CreateConverter(client, path);
 }
Esempio n. 19
0
        public void Create_ReturnsBinding_IfContainsResolvedGenericParameter()
        {
            // Arrange
            ITableEntityArgumentBindingProvider product = new PocoEntityArgumentBindingProvider();
            Type parameterType = typeof(GenericClass <SimpleTableEntity>);
            // Act
            IArgumentBinding <TableEntityContext> binding = product.TryCreate(_parameters[1]);

            // Assert
            Assert.NotNull(binding);
        }
Esempio n. 20
0
        public void Create_ReturnsNull_IfByRefParameter()
        {
            // Arrange
            ITableEntityArgumentBindingProvider product = new PocoEntityArgumentBindingProvider();
            Type parameterType = typeof(SimpleTableEntity).MakeByRefType();
            // Act
            IArgumentBinding <TableEntityContext> binding = product.TryCreate(_parameters[0]);

            // Assert
            Assert.Null(binding);
        }
 public ServiceBusBinding(string parameterName, IArgumentBinding <ServiceBusEntity> argumentBinding, ServiceBusAccount account, IBindableServiceBusPath path, ServiceBusAttribute attr)
 {
     _parameterName   = parameterName;
     _argumentBinding = argumentBinding;
     _account         = account;
     _namespaceName   = ServiceBusClient.GetNamespaceName(account);
     _path            = path;
     _accessRights    = attr.Access;
     _entityType      = attr.EntityType;
     _converter       = new OutputConverter <string>(
         new StringToServiceBusEntityConverter(account, _path, _accessRights, _entityType));
 }
        public RedisBinding(string parameterName, IArgumentBinding<RedisEntity> argumentBinding,
            RedisAccount account, RedisAttribute attribute, BindingProviderContext context, TraceWriter trace)
        {
            _parameterName = parameterName;
            _argumentBinding = argumentBinding;
            _account = account;
            _attribute = attribute;
            _mode = attribute.Mode;

            _channelOrKeyPath = BindingTemplate.FromString(attribute.ChannelOrKey);
            _trace = trace;
        }
        public RedisBinding(string parameterName, IArgumentBinding <RedisEntity> argumentBinding,
                            RedisAccount account, RedisAttribute attribute, BindingProviderContext context, TraceWriter trace)
        {
            _parameterName   = parameterName;
            _argumentBinding = argumentBinding;
            _account         = account;
            _attribute       = attribute;
            _mode            = attribute.Mode;

            _channelOrKeyPath = BindingTemplate.FromString(attribute.ChannelOrKey);
            _trace            = trace;
        }
Esempio n. 24
0
        public void Create_ReturnsNull_IfContainsUnresolvedGenericParameter()
        {
            // Arrange
            ITableEntityArgumentBindingProvider product = new TableEntityArgumentBindingProvider();

            Type parameterType = typeof(GenericClass <>);

            // Act
            IArgumentBinding <TableEntityContext> binding = product.TryCreate(parameterType);

            // Assert
            Assert.Null(binding);
        }
Esempio n. 25
0
        public IArgumentBinding <ServiceBusEntity> TryCreate(ParameterInfo parameter)
        {
            foreach (IQueueArgumentBindingProvider provider in _providers)
            {
                IArgumentBinding <ServiceBusEntity> binding = provider.TryCreate(parameter);

                if (binding != null)
                {
                    return(binding);
                }
            }

            return(null);
        }
Esempio n. 26
0
        public IArgumentBinding <TBindingData> TryCreate(ParameterInfo parameter)
        {
            foreach (IDataArgumentBindingProvider <TBindingData> provider in _providers)
            {
                IArgumentBinding <TBindingData> binding = provider.TryCreate(parameter);

                if (binding != null)
                {
                    return(binding);
                }
            }

            return(null);
        }
        public IArgumentBinding <IStorageBlobContainer> TryCreate(ParameterInfo parameter)
        {
            foreach (IBlobContainerArgumentBindingProvider provider in _providers)
            {
                IArgumentBinding <IStorageBlobContainer> binding = provider.TryCreate(parameter);

                if (binding != null)
                {
                    return(binding);
                }
            }

            return(null);
        }
        public IArgumentBinding <TableEntityContext> TryCreate(Type parameterType)
        {
            foreach (ITableEntityArgumentBindingProvider provider in _providers)
            {
                IArgumentBinding <TableEntityContext> binding = provider.TryCreate(parameterType);

                if (binding != null)
                {
                    return(binding);
                }
            }

            return(null);
        }
Esempio n. 29
0
        public IArgumentBinding <IStorageQueue> TryCreate(ParameterInfo parameter)
        {
            foreach (IQueueArgumentBindingProvider provider in _providers)
            {
                IArgumentBinding <IStorageQueue> binding = provider.TryCreate(parameter);

                if (binding != null)
                {
                    return(binding);
                }
            }

            return(null);
        }
 public ServiceBusBinding(
     string parameterName,
     IArgumentBinding <ServiceBusEntity> argumentBinding,
     IBindableServiceBusPath path,
     ServiceBusAttribute attribute,
     MessagingProvider messagingProvider,
     ServiceBusClientFactory clientFactory)
 {
     _parameterName     = parameterName;
     _argumentBinding   = argumentBinding;
     _path              = path;
     _messagingProvider = messagingProvider;
     _clientFactory     = clientFactory;
     _attribute         = attribute;
     _converter         = new OutputConverter <string>(new StringToServiceBusEntityConverter(_attribute, _path, _messagingProvider, _clientFactory));
 }
Esempio n. 31
0
 public KafkaAttributeBinding(
     string parameterName,
     KafkaAttribute attribute,
     IKafkaProducerFactory kafkaProducerFactory,
     IArgumentBinding <KafkaProducerEntity> argumentBinding,
     Type keyType,
     Type valueType,
     string avroSchema)
 {
     this.parameterName        = parameterName;
     this.attribute            = attribute ?? throw new ArgumentNullException(nameof(attribute));
     this.kafkaProducerFactory = kafkaProducerFactory ?? throw new ArgumentNullException(nameof(kafkaProducerFactory));
     this.argumentBinding      = argumentBinding ?? throw new ArgumentNullException(nameof(argumentBinding));
     this.keyType    = keyType;
     this.valueType  = valueType ?? throw new ArgumentNullException(nameof(valueType));
     this.avroSchema = avroSchema;
 }
        private IBinding TryCreate(BindingProviderContext context)
        {
            ParameterInfo parameter      = context.Parameter;
            var           tableAttribute = TypeUtility.GetResolvedAttribute <TableAttribute>(context.Parameter);

            if (tableAttribute == null)
            {
                return(null);
            }

            string tableName = Resolve(tableAttribute.TableName);
            var    account   = _accountProvider.Get(tableAttribute.Connection, _nameResolver);
            // requires storage account with table support
            // account.AssertTypeOneOf(StorageAccountType.GeneralPurpose); $$$

            CloudTableClient client = account.CreateCloudTableClient();

            bool     bindsToEntireTable = tableAttribute.RowKey == null;
            IBinding binding;

            if (bindsToEntireTable)
            {
                // This should have been caught by the other rule-based binders.
                // We never expect this to get thrown.
                throw new InvalidOperationException("Can't bind Table to type '" + parameter.ParameterType + "'.");
            }
            else
            {
                string partitionKey           = Resolve(tableAttribute.PartitionKey);
                string rowKey                 = Resolve(tableAttribute.RowKey);
                IBindableTableEntityPath path = BindableTableEntityPath.Create(tableName, partitionKey, rowKey);
                path.ValidateContractCompatibility(context.BindingDataContract);

                IArgumentBinding <TableEntityContext> argumentBinding = _entityBindingProvider.TryCreate(parameter);

                if (argumentBinding == null)
                {
                    throw new InvalidOperationException("Can't bind Table entity to type '" + parameter.ParameterType + "'.");
                }

                binding = new TableEntityBinding(parameter.Name, argumentBinding, client, path);
            }

            return(binding);
        }
Esempio n. 33
0
        public async Task <IBinding> TryCreateAsync(BindingProviderContext context)
        {
            ParameterInfo parameter     = context.Parameter;
            BlobAttribute blobAttribute = parameter.GetCustomAttribute <BlobAttribute>(inherit: false);

            if (blobAttribute == null)
            {
                return(null);
            }

            string            resolvedPath = Resolve(blobAttribute.BlobPath);
            IBindableBlobPath path         = null;
            IStorageAccount   account      = await _accountProvider.GetStorageAccountAsync(context.Parameter, context.CancellationToken);

            StorageClientFactoryContext clientFactoryContext = new StorageClientFactoryContext
            {
                Parameter = context.Parameter
            };
            IStorageBlobClient client = account.CreateBlobClient(clientFactoryContext);

            // first try to bind to the Container
            IArgumentBinding <IStorageBlobContainer> containerArgumentBinding = _blobContainerArgumentProvider.TryCreate(parameter);

            if (containerArgumentBinding == null)
            {
                // if this isn't a Container binding, try a Blob binding
                IBlobArgumentBinding blobArgumentBinding = _blobArgumentProvider.TryCreate(parameter, blobAttribute.Access);
                if (blobArgumentBinding == null)
                {
                    throw new InvalidOperationException("Can't bind Blob to type '" + parameter.ParameterType + "'.");
                }

                path = BindableBlobPath.Create(resolvedPath);
                path.ValidateContractCompatibility(context.BindingDataContract);

                return(new BlobBinding(parameter.Name, blobArgumentBinding, client, path));
            }

            path = BindableBlobPath.Create(resolvedPath, isContainerBinding: true);
            path.ValidateContractCompatibility(context.BindingDataContract);
            BlobContainerBinding.ValidateContainerBinding(blobAttribute, parameter.ParameterType, path);

            return(new BlobContainerBinding(parameter.Name, containerArgumentBinding, client, path));
        }
        public Task <IBinding> TryCreateAsync(BindingProviderContext context)
        {
            ParameterInfo parameter = context.Parameter;

            IArgumentBinding <TBindingData> argumentBinding = _innerProvider.TryCreate(parameter);

            string parameterName = parameter.Name;
            Type   parameterType = parameter.ParameterType;

            if (argumentBinding == null)
            {
                throw new InvalidOperationException(
                          "Can't bind parameter '" + parameterName + "' to type '" + parameterType + "'.");
            }

            IBinding binding = new ClassDataBinding <TBindingData>(parameterName, argumentBinding);

            return(Task.FromResult(binding));
        }
Esempio n. 35
0
        private IBinding TryCreate(BindingProviderContext context)
        {
            ParameterInfo parameter      = context.Parameter;
            var           tableAttribute = TypeUtility.GetResolvedAttribute <TableAttribute>(context.Parameter);

            if (tableAttribute == null)
            {
                return(null);
            }

            // JArray is bound by the next binding
            if (parameter.ParameterType == typeof(JArray))
            {
                return(null);
            }

            string tableName          = Resolve(tableAttribute.TableName);
            var    account            = _accountProvider.Get(tableAttribute.Connection, _nameResolver);
            bool   bindsToEntireTable = tableAttribute.RowKey == null;

            if (bindsToEntireTable)
            {
                // This should have been caught by the other rule-based binders.
                // We never expect this to get thrown.
                throw new InvalidOperationException("Can't bind Table to type '" + parameter.ParameterType + "'.");
            }

            string partitionKey           = Resolve(tableAttribute.PartitionKey);
            string rowKey                 = Resolve(tableAttribute.RowKey);
            IBindableTableEntityPath path = BindableTableEntityPath.Create(tableName, partitionKey, rowKey);

            path.ValidateContractCompatibility(context.BindingDataContract);
            IArgumentBinding <TableEntityContext> argumentBinding = TryCreatePocoBinding(parameter, _converterManager);

            if (argumentBinding == null)
            {
                throw new InvalidOperationException("Can't bind Table entity to type '" + parameter.ParameterType + "'.");
            }

            return(new TableEntityBinding(parameter.Name, argumentBinding, account, path));
        }
        public BlobTriggerBinding(ParameterInfo parameter,
            IArgumentBinding<IStorageBlob> argumentBinding,
            IStorageAccount hostAccount,
            IStorageAccount dataAccount,
            IBlobPathSource path,
            IHostIdProvider hostIdProvider,
            IQueueConfiguration queueConfiguration,
            IBackgroundExceptionDispatcher backgroundExceptionDispatcher,
            IContextSetter<IBlobWrittenWatcher> blobWrittenWatcherSetter,
            IContextSetter<IMessageEnqueuedWatcher> messageEnqueuedWatcherSetter,
            ISharedContextProvider sharedContextProvider,
            TraceWriter trace)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter");
            }

            if (argumentBinding == null)
            {
                throw new ArgumentNullException("argumentBinding");
            }

            if (hostAccount == null)
            {
                throw new ArgumentNullException("hostAccount");
            }

            if (dataAccount == null)
            {
                throw new ArgumentNullException("dataAccount");
            }

            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            if (hostIdProvider == null)
            {
                throw new ArgumentNullException("hostIdProvider");
            }

            if (queueConfiguration == null)
            {
                throw new ArgumentNullException("queueConfiguration");
            }

            if (backgroundExceptionDispatcher == null)
            {
                throw new ArgumentNullException("backgroundExceptionDispatcher");
            }

            if (blobWrittenWatcherSetter == null)
            {
                throw new ArgumentNullException("blobWrittenWatcherSetter");
            }

            if (messageEnqueuedWatcherSetter == null)
            {
                throw new ArgumentNullException("messageEnqueuedWatcherSetter");
            }

            if (sharedContextProvider == null)
            {
                throw new ArgumentNullException("sharedContextProvider");
            }

            if (trace == null)
            {
                throw new ArgumentNullException("trace");
            }

            _parameter = parameter;
            _argumentBinding = argumentBinding;
            _hostAccount = hostAccount;
            _dataAccount = dataAccount;
            StorageClientFactoryContext context = new StorageClientFactoryContext
            {
                Parameter = parameter
            };
            _blobClient = dataAccount.CreateBlobClient(context);
            _accountName = BlobClient.GetAccountName(_blobClient);
            _path = path;
            _hostIdProvider = hostIdProvider;
            _queueConfiguration = queueConfiguration;
            _backgroundExceptionDispatcher = backgroundExceptionDispatcher;
            _blobWrittenWatcherSetter = blobWrittenWatcherSetter;
            _messageEnqueuedWatcherSetter = messageEnqueuedWatcherSetter;
            _sharedContextProvider = sharedContextProvider;
            _trace = trace;
            _converter = CreateConverter(_blobClient);
            _bindingDataContract = CreateBindingDataContract(path);
        }
        public BlobTriggerBinding(string parameterName,
            IArgumentBinding<IStorageBlob> argumentBinding,
            IStorageAccount account,
            IBlobPathSource path,
            IHostIdProvider hostIdProvider,
            IQueueConfiguration queueConfiguration,
            IBackgroundExceptionDispatcher backgroundExceptionDispatcher,
            IContextSetter<IBlobWrittenWatcher> blobWrittenWatcherSetter,
            IContextSetter<IMessageEnqueuedWatcher> messageEnqueuedWatcherSetter,
            ISharedContextProvider sharedContextProvider,
            TextWriter log)
        {
            if (argumentBinding == null)
            {
                throw new ArgumentNullException("argumentBinding");
            }

            if (account == null)
            {
                throw new ArgumentNullException("account");
            }

            if (path == null)
            {
                throw new ArgumentNullException("path");
            }

            if (hostIdProvider == null)
            {
                throw new ArgumentNullException("hostIdProvider");
            }

            if (queueConfiguration == null)
            {
                throw new ArgumentNullException("queueConfiguration");
            }

            if (backgroundExceptionDispatcher == null)
            {
                throw new ArgumentNullException("backgroundExceptionDispatcher");
            }

            if (blobWrittenWatcherSetter == null)
            {
                throw new ArgumentNullException("blobWrittenWatcherSetter");
            }

            if (messageEnqueuedWatcherSetter == null)
            {
                throw new ArgumentNullException("messageEnqueuedWatcherSetter");
            }

            if (sharedContextProvider == null)
            {
                throw new ArgumentNullException("sharedContextProvider");
            }

            if (log == null)
            {
                throw new ArgumentNullException("log");
            }

            _parameterName = parameterName;
            _argumentBinding = argumentBinding;
            _account = account;
            _client = account.CreateBlobClient();
            _accountName = BlobClient.GetAccountName(_client);
            _path = path;
            _hostIdProvider = hostIdProvider;
            _queueConfiguration = queueConfiguration;
            _backgroundExceptionDispatcher = backgroundExceptionDispatcher;
            _blobWrittenWatcherSetter = blobWrittenWatcherSetter;
            _messageEnqueuedWatcherSetter = messageEnqueuedWatcherSetter;
            _sharedContextProvider = sharedContextProvider;
            _log = log;
            _converter = CreateConverter(_client);
            _bindingDataContract = CreateBindingDataContract(path);
        }