public static IServiceCollection AddMessaging(this IServiceCollection services, IConfiguration configuration, Action <MessagingOptions> options) { var messagingOptions = new MessagingOptions(); options?.Invoke(messagingOptions); var providersSection = configuration.GetSection("Inbound:Providers"); var providers = providersSection.GetChildren() .Select(section => messagingOptions.GetProviderFactory(section["Type"])(section)) .ToList(); services.AddSingleton <IReceiveEndpoint, ReceiveEndpoint>(); services.AddTransient <IExceptionHandler, ExceptionHandler>(); services.AddSingleton(serviceProvider => { return(providers.SelectMany(x => x.Provide()).ToArray()); }); return(services); }
public static MessagingOptions AddAzureStorageQueues(this MessagingOptions options) { options.RegisterProviderFactory("AzureStorageQueues", configuration => new AzureStorageQueueDefinitionProvider(configuration)); return(options); }