using Azure.Identity;
using Core.Blueprint.DAL.SQLServer;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace Core.Blueprint.SQLServer.Configuration
{
    /// 
    /// Provides extension methods for configuring SQL Server.
    /// 
    public static class RegisterBlueprint
    {
        /// 
        /// Configures SQL Server services, including the database context and generic repository, for dependency injection.
        /// 
        /// The service collection to which the SQL Server services will be added.
        /// The application configuration object for accessing settings such as connection strings.
        /// An updated  with SQL Server services registered.
        public static IServiceCollection AddSQLServer(this IServiceCollection services, IConfiguration configuration)
        {
            var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? string.Empty;
                var chainedCredentials = new ChainedTokenCredential(
                    new ManagedIdentityCredential(),
                    new SharedTokenCacheCredential(),
                    new VisualStudioCredential(),
                    new VisualStudioCodeCredential()
                );
            services.AddScoped(typeof(IEntityRepository<,>), typeof(EntityRepository<,>));
            return services;
        }
    }
}