using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using System;
using System.Collections.Generic;
using System.Text;

namespace TEAMModelOS.SDK.DI
{
    public static class AzureServiceBusFactoryExtensions
    {
        public static IServiceCollection AddAzureServiceBus(this IServiceCollection services, string connectionString, string name = "Default")
        {
            if (services == null) throw new ArgumentNullException(nameof(services));            
            if (connectionString == null) throw new ArgumentNullException(nameof(connectionString));

            services.TryAddSingleton<AzureServiceBusFactory>();
            services.Configure<AzureServiceBusFactoryOptions>(name, o => { o.Name = name; o.ServiceBusConnectionString = connectionString; });

            return services;
        }
    }
}
