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 AzureRedisFactoryExtensions
    {
        public static IServiceCollection AddAzureRedis(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<AzureRedisFactory>();
            services.Configure<AzureRedisFactoryOptions>(name, o => { o.Name = name; o.RedisConnectionString = connectionString; });

            return services;
        }
    }
}
