1
This commit is contained in:
43
Yes.Application/DependencyInjection.cs
Normal file
43
Yes.Application/DependencyInjection.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
namespace Yes.Application
|
||||
{
|
||||
public static class DependencyInjection
|
||||
{
|
||||
private readonly static Assembly[] Assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
|
||||
public static IServiceCollection RegisterApplicationModule(this IServiceCollection services)
|
||||
{
|
||||
|
||||
services.AddMediatR();
|
||||
services.AddAutoMapper();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddAutoMapper(this IServiceCollection services)
|
||||
{
|
||||
var typeAdapterConfig = TypeAdapterConfig.GlobalSettings;
|
||||
typeAdapterConfig.Scan(Assemblies);
|
||||
|
||||
services.AddSingleton(typeAdapterConfig);
|
||||
services.AddScoped<IMapper, ServiceMapper>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
|
||||
public static IServiceCollection AddMediatR(this IServiceCollection services)
|
||||
{
|
||||
|
||||
var application = typeof(IAssembly);
|
||||
|
||||
services.AddMediatR(configure =>
|
||||
{
|
||||
configure.RegisterServicesFromAssembly(application.Assembly);
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user