mirror of
https://github.com/techgarage-ir/MTWireGuard.git
synced 2025-08-24 19:35:22 +02:00
34 lines
1.2 KiB
C#
34 lines
1.2 KiB
C#
|
using Microsoft.Extensions.DependencyInjection;
|
|||
|
using MTWireGuard;
|
|||
|
using MTWireGuard.Application.Mapper;
|
|||
|
using MTWireGuard.Application.Repositories;
|
|||
|
using MTWireGuard.Application.Services;
|
|||
|
using System.Reflection;
|
|||
|
|
|||
|
namespace MTWireGuard.Application
|
|||
|
{
|
|||
|
public static class ApplicationServiceRegister
|
|||
|
{
|
|||
|
public static void AddApplicationServices(this IServiceCollection services)
|
|||
|
{
|
|||
|
// Add DBContext
|
|||
|
services.AddDbContext<DBContext>(ServiceLifetime.Singleton);
|
|||
|
|
|||
|
// Auto Mapper Configurations
|
|||
|
services.AddSingleton<PeerMapping>();
|
|||
|
services.AddSingleton<ServerMapping>();
|
|||
|
services.AddSingleton<MappingProfile>();
|
|||
|
services.AddAutoMapper(
|
|||
|
(provider, expression) => {
|
|||
|
expression.AddProfile(provider.GetService<PeerMapping>());
|
|||
|
expression.AddProfile(provider.GetService<ServerMapping>());
|
|||
|
expression.AddProfile(provider.GetService<MappingProfile>());
|
|||
|
},
|
|||
|
new List<Assembly>());
|
|||
|
|
|||
|
// Add Mikrotik API Service
|
|||
|
services.AddSingleton<IMikrotikRepository, MTAPI>();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|