// Create a bindingContext. 
        // parameters takes precedence over existingBindingData.
        internal static BindingContext NewBindingContext(
            ValueBindingContext context, 
            IReadOnlyDictionary<string, object> existingBindingData,  
            IDictionary<string, object> parameters)
        {
            // if bindingData was a mutable dictionary, we could just add it. 
            // But since it's read-only, must create a new one. 
            Dictionary<string, object> bindingData = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
            if (existingBindingData != null)
            {
                foreach (var kv in existingBindingData)
                {
                    bindingData[kv.Key] = kv.Value;
                }
            }
            if (parameters != null)
            {
                foreach (var kv in parameters)
                {
                    bindingData[kv.Key] = kv.Value;
                }
            }

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

            return await BindBlobContainerAsync(container, containerContext);
        }
        public Task<IValueProvider> BindAsync(BindingContext context)
        {
            context.CancellationToken.ThrowIfCancellationRequested();

            var entity = CreateEntity(context.BindingData);

            return BindAsync(entity, context.ValueContext);
        }
        public Task<IValueProvider> BindAsync(BindingContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            string boundTableName = _path.Bind(context.BindingData);
            IStorageTable table = _client.GetTableReference(boundTableName);

            return BindTableAsync(table, context.ValueContext);
        }
            public Task<IValueProvider> BindAsync(BindingContext context)
            {
                if (context == null)
                {
                    throw new ArgumentNullException("context");
                }

                return BindInternalAsync(new ExecutionContext
                {
                    InvocationId = context.FunctionInstanceId
                });
            }
        public Task<IValueProvider> BindAsync(BindingContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            string boundFileName = _bindingTemplate.Bind(context.BindingData);
            string filePath = Path.Combine(_config.RootPath, boundFileName);
            FileInfo fileInfo = new FileInfo(filePath);

            return BindAsync(fileInfo, context.ValueContext);
        }
        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<IValueProvider> BindAsync(BindingContext context)
        {
            context.CancellationToken.ThrowIfCancellationRequested();

            string boundQueueName = _path.Bind(context.BindingData);
            MessageSender messageSender = await _account.MessagingFactory.CreateMessageSenderAsync(boundQueueName);

            ServiceBusEntity entity = new ServiceBusEntity
            {
                Account = _account,
                MessageSender = messageSender,
                AccessRights = _accessRights
            };

            return await BindAsync(entity, context.ValueContext);
        }
        public async Task<IReadOnlyDictionary<string, IValueProvider>> BindAsync(ValueBindingContext context, IDictionary<string, object> parameters)
        {
            Dictionary<string, IValueProvider> results = new Dictionary<string, IValueProvider>();

            BindingContext bindingContext = new BindingContext(context, null);

            // bind Singleton if specified
            SingletonAttribute singletonAttribute = SingletonManager.GetFunctionSingletonOrNull(_descriptor.Method, isTriggered: false);
            if (singletonAttribute != null)
            {
                string boundScope = _singletonManager.GetBoundScope(singletonAttribute.Scope);
                IValueProvider singletonValueProvider = new SingletonValueProvider(_descriptor.Method, boundScope, context.FunctionInstanceId.ToString(), singletonAttribute, _singletonManager);
                results.Add(SingletonValueProvider.SingletonParameterName, singletonValueProvider);
            }

            foreach (KeyValuePair<string, IBinding> item in _bindings)
            {
                string name = item.Key;
                IBinding binding = item.Value;
                IValueProvider valueProvider;

                try
                {
                    if (parameters != null && parameters.ContainsKey(name))
                    {
                        valueProvider = await binding.BindAsync(parameters[name], context);
                    }
                    else
                    {
                        valueProvider = await binding.BindAsync(bindingContext);
                    }
                }
                catch (OperationCanceledException)
                {
                    throw;
                }
                catch (Exception exception)
                {
                    valueProvider = new BindingExceptionValueProvider(name, exception);
                }

                results.Add(name, valueProvider);
            }

            return results;
        }
        public Task<IValueProvider> BindAsync(BindingContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            FileInfo fileInfo = null;
            if (context != null)
            {
                BindablePath path = new BindablePath(_attribute.Path);
                string boundFileName = path.Bind(context.BindingData);
                string filePath = Path.Combine(_config.RootPath, boundFileName);
                fileInfo = new FileInfo(filePath);
            }

            return BindAsync(fileInfo, context.ValueContext);
        }
        public Task<IValueProvider> BindAsync(BindingContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            TableEntityPath boundPath = _path.Bind(context.BindingData);
            IStorageTable table = _client.GetTableReference(boundPath.TableName);

            TableEntityContext entityContext = new TableEntityContext
            {
                Table = table,
                PartitionKey = boundPath.PartitionKey,
                RowKey = boundPath.RowKey
            };

            return BindEntityAsync(entityContext, context.ValueContext);
        }
        public Task<IValueProvider> BindAsync(BindingContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            object tracer = null;
            if (_parameter.ParameterType == typeof(TraceWriter))
            {
                // bind directly to the context TraceWriter
                tracer = context.Trace;
            }
            else
            {
                // bind to an adapter
                tracer = new TextWriterTraceAdapter(context.Trace);
            }

            return BindAsync(tracer, context.ValueContext);
        }
        public async Task<IReadOnlyDictionary<string, IValueProvider>> BindAsync(ValueBindingContext context, IDictionary<string, object> parameters)
        {
            Dictionary<string, IValueProvider> results = new Dictionary<string, IValueProvider>();
            IReadOnlyDictionary<string, object> bindingData = null;

            BindingContext bindingContext = new BindingContext(context, bindingData);

            foreach (KeyValuePair<string, IBinding> item in _bindings)
            {
                string name = item.Key;
                IBinding binding = item.Value;
                IValueProvider valueProvider;

                try
                {
                    if (parameters != null && parameters.ContainsKey(name))
                    {
                        valueProvider = await binding.BindAsync(parameters[name], context);
                    }
                    else
                    {
                        valueProvider = await binding.BindAsync(bindingContext);
                    }
                }
                catch (OperationCanceledException)
                {
                    throw;
                }
                catch (Exception exception)
                {
                    valueProvider = new BindingExceptionValueProvider(name, exception);
                }

                results.Add(name, valueProvider);
            }

            return results;
        }
 private static BindingContext GetCtx(IReadOnlyDictionary<string, object> values)
 {
     BindingContext ctx = new BindingContext(
         new ValueBindingContext(null, CancellationToken.None),
         values);
     return ctx;
 }
        public async Task<Microsoft.Azure.WebJobs.Host.Bindings.IValueProvider> BindAsync(BindingContext context)
        {
            SlackMessage message = CreateDefaultMessage(context.BindingData);

            return await BindAsync(message, context.ValueContext);
        }
 public Task<IValueProvider> BindAsync(BindingContext context)
 {
     return Task.FromResult<IValueProvider>(new SampleValueBinder(_parameter));
 }
Example #17
0
 public Task <IValueProvider> BindAsync(BindingContext context)
 {
     // Never called, since a trigger alreayd has an object.
     throw new NotImplementedException();
 }
            public async Task<IValueProvider> BindAsync(BindingContext context)
            {
                SendGridMessage message = CreateDefaultMessage(context.BindingData);

                return await BindAsync(message, context.ValueContext);
            }
Example #19
0
        public TAttribute ResolveFromBindingData(BindingContext ctx)
        {
            var attr = ResolveFromBindings(ctx.BindingData);

            return(attr);
        }
 public Task<IValueProvider> BindAsync(BindingContext context) =>
     Task.FromResult<IValueProvider>(new FtpValueBinder(new FtpClient(_config), _config, _ftpAttribute));