39 lines
1.5 KiB
C#
39 lines
1.5 KiB
C#
namespace LaaProduction
|
|
{
|
|
using LaaProduction.Personalization;
|
|
using LaaProduction.Search;
|
|
using LaaProductionHttp;
|
|
using LaaProductionSQL;
|
|
using LaaProduction.Web.App_Infrastructure;
|
|
using LaaProduction.Services;
|
|
using LaaProduction.Services.Interfaces;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using System;
|
|
|
|
public class ServiceProvider
|
|
{
|
|
private static IServiceProvider serviceProvider;
|
|
|
|
public static T GetService<T>() where T : class
|
|
=> serviceProvider.GetService<T>();
|
|
|
|
public static void RegisterServices()
|
|
=> serviceProvider = new ServiceCollection()
|
|
.AddSingleton(_ => SQLConnection.CreateConnection(Appsettings.ConnectionString))
|
|
.AddSingleton(_ => HttpClient.CreateHttpClient(Appsettings.APIURL))
|
|
.AddAdministration(Appsettings.ConnectionString)
|
|
.AddSearching(Appsettings.ConnectionString)
|
|
.AddScoped<IAccountService, AccountService>()
|
|
.AddScoped<IApprovalsService, ApprovalsService>()
|
|
.AddScoped<ILoggerService, LoggerService>()
|
|
.AddScoped<IOrdersService, OrdersService>()
|
|
.AddScoped<IProtocolService, ProtocolService>()
|
|
.AddScoped<IReportService, ReportService>()
|
|
.AddScoped<ISearchService, SearchService>()
|
|
.AddScoped<IShipmentsService, ShipmentsService>()
|
|
.AddScoped<ISoftwareService, SoftwareService>()
|
|
.BuildServiceProvider();
|
|
}
|
|
} |