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); Func <string, EventHubClient> invokeStringBinder = (invokeString) => _eventHubConfig.GetEventHubClient(invokeString); IBinding binding = BindingFactory.BindCollector <EventData, EventHubClient>( parameter, _converterManager, (client, valueBindingContext) => new EventHubAsyncCollector(client), resolvedName, invokeStringBinder); return(Task.FromResult(binding)); }
public Task <IBinding> TryCreateAsync(BindingProviderContext context) { if (context == null) { throw new ArgumentNullException("context"); } ParameterInfo parameter = context.Parameter; NotificationHubAttribute attribute = parameter.GetCustomAttribute <NotificationHubAttribute>(inherit: false); if (attribute == null) { return(Task.FromResult <IBinding>(null)); } if (string.IsNullOrEmpty(_config.ConnectionString) && string.IsNullOrEmpty(attribute.ConnectionString)) { throw new InvalidOperationException( string.Format(CultureInfo.CurrentCulture, "The Notification Hub connection string must be set either via a '{0}' app setting, via the NotificationHubAttribute.ConnectionString property or via NotificationHubsConfiguration.ConnectionString.", NotificationHubsConfiguration.NotificationHubConnectionStringName)); } if (string.IsNullOrEmpty(_config.HubName) && string.IsNullOrEmpty(attribute.HubName)) { throw new InvalidOperationException( string.Format(CultureInfo.CurrentCulture, "The Notification Hub hub name must be set either via a '{0}' app setting, via the NotificationHubAttribute.HubName property or via NotificationHubsConfiguration.HubName.", NotificationHubsConfiguration.NotificationHubSettingName)); } string resolvedConnectionString = ResolveConnectionString(_config.ConnectionString, attribute.ConnectionString); string resolvedHubName = ResolveHubName(_config.HubName, attribute.HubName); INotificationHubClientService service = new NotificationHubClientService(resolvedConnectionString, resolvedHubName); Func <string, INotificationHubClientService> invokeStringBinder = (invokeString) => service; IBinding binding = BindingFactory.BindCollector( parameter, _converterManager, (nhClientService, valueBindingContext) => new NotificationHubAsyncCollector(service, attribute.TagExpression), "NotificationHubs", invokeStringBinder); return(Task.FromResult(binding)); }
public Task <IBinding> TryCreateAsync(BindingProviderContext context) { ParameterInfo parameter = context.Parameter; FakeQueueAttribute attribute = parameter.GetCustomAttribute <FakeQueueAttribute>(inherit: false); if (attribute == null) { return(Task.FromResult <IBinding>(null)); } string resolvedName = "fakequeue"; Func <string, FakeQueueClient> invokeStringBinder = (invokeString) => _client; IBinding binding = BindingFactory.BindCollector <FakeQueueData, FakeQueueClient>( parameter, _converterManager, (client, valueBindingContext) => client, resolvedName, invokeStringBinder ); return(Task.FromResult(binding)); }