public Task <ITriggerBinding> TryCreateAsync(TriggerBindingProviderContext context) { if (context == null) { throw new ArgumentNullException("context"); } ParameterInfo parameter = context.Parameter; EventHubTriggerAttribute attribute = parameter.GetCustomAttribute <EventHubTriggerAttribute>(inherit: false); if (attribute == null) { return(Task.FromResult <ITriggerBinding>(null)); } string eventHubName = attribute.EventHubName; string resolvedName = _nameResolver.ResolveWholeString(eventHubName); var eventHostListener = _eventHubConfig.GetEventProcessorHost(resolvedName); var options = _eventHubConfig.GetOptions(); var hooks = new EventHubTriggerBindingStrategy(); Func <ListenerFactoryContext, bool, Task <IListener> > createListener = (factoryContext, singleDispatch) => { IListener listener = new EventHubListener(factoryContext.Executor, eventHostListener, options, singleDispatch); return(Task.FromResult(listener)); }; ITriggerBinding binding = GenericBinder.GetTriggerBinding <EventData, EventHubTriggerInput>(hooks, parameter, _converterManager, createListener); return(Task.FromResult <ITriggerBinding>(binding)); }
public Task <IBinding> TryCreateAsync(BindingProviderContext context) { if (context == null) { throw new ArgumentNullException("context"); } ParameterInfo parameter = context.Parameter; EventHubAttribute attribute = parameter.GetCustomAttribute <EventHubAttribute>(inherit: false); if (attribute == null) { return(Task.FromResult <IBinding>(null)); } string name = attribute.EventHubName; var resolvedName = _nameResolver.ResolveWholeString(name); var eventHubClient = _eventHubConfig.GetEventHubClient(resolvedName); Func <string, EventHubClient> invokeStringBinder = (invokeString) => _eventHubConfig.GetEventHubClient(invokeString); IBinding binding = GenericBinder.BindCollector <EventData, EventHubClient>( parameter, _converterManager, eventHubClient, (client, valueBindingContext) => new EventHubAsyncCollector(client), resolvedName, invokeStringBinder ); return(Task.FromResult(binding)); }
public static ITriggerBinding GetTriggerBinding <TMessage, TTriggerValue>( ITriggerBindingStrategy <TMessage, TTriggerValue> hooks, ParameterInfo parameter, IConverterManager converterManager, Func <ListenerFactoryContext, bool, Task <IListener> > createListener ) { bool singleDispatch; var argumentBinding = GenericBinder.GetTriggerArgumentBinding(hooks, parameter, converterManager, out singleDispatch); var parameterDescriptor = new ParameterDescriptor { Name = parameter.Name, DisplayHints = new ParameterDisplayHints { Description = singleDispatch ? "message" : "messages" } }; ITriggerBinding binding = new CommonTriggerBinding <TMessage, TTriggerValue>( hooks, argumentBinding, createListener, parameterDescriptor, singleDispatch); return(binding); }