using System;
using System.Reflection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using Aurora.Infrastructure.User;
using Aurora.Infrastructure.Tenant;
using Aurora.Common.User;
using Aurora.Common.Tenant;

namespace Aurora.Common
{
    public static class CommonExtensions
    {
        public static IServiceCollection AddCommonService(this IServiceCollection services)
        {
            if (services == null)
            {
                throw new ArgumentNullException("services");
            }
 
            //注入请求上下文
            services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>(); 
            
            services.AddSingleton<IUsersCache, UsersCache>();
            services.AddScoped<IUserContextProvider, UserContextProvider>();
            services.AddScoped<ITenantContextProvider, TenantContextProvider>(); 

            return services;
        }

    }
}
