feat(DIExtensions): Methoden zur Injektion von Workflow-Diensten und mit TryAddScoped-Methode erstellt.
- Umwandlung von AddScoped in TryAddScoped in der Methode AddWorkFlowRepositories. - Methode mit dem Namen AddWorkFlow erstellt, um Dienste und Repositories zusammen hinzuzufügen
This commit is contained in:
parent
56344afdc8
commit
1b21ccecf3
25
WorkFlow.Application/DIExtensions.cs
Normal file
25
WorkFlow.Application/DIExtensions.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
|
using WorkFlow.Application.Contracts;
|
||||||
|
using WorkFlow.Application.Services;
|
||||||
|
using WorkFlow.Infrastructure;
|
||||||
|
|
||||||
|
namespace WorkFlow.Application
|
||||||
|
{
|
||||||
|
public static class DIExtensions
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddWorkFlowServices(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddAutoMapper(typeof(MappingProfile).Assembly);
|
||||||
|
services.TryAddScoped<IConfigService, ConfigService>();
|
||||||
|
services.TryAddScoped<IProfileControlsTFService, ProfileControlsTFService>();
|
||||||
|
services.TryAddScoped<IProfileObjStateService, ProfileObjStateService>();
|
||||||
|
services.TryAddScoped<IProfileService, ProfileService>();
|
||||||
|
services.TryAddScoped<IStateService, StateService>();
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IServiceCollection AddWorkFlow(this IServiceCollection services) => services.AddWorkFlowRepositories().AddWorkFlowServices();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
using WorkFlow.Infrastructure.Contracts;
|
using WorkFlow.Infrastructure.Contracts;
|
||||||
using WorkFlow.Infrastructure.Repositories;
|
using WorkFlow.Infrastructure.Repositories;
|
||||||
|
|
||||||
@ -6,11 +7,15 @@ namespace WorkFlow.Infrastructure
|
|||||||
{
|
{
|
||||||
public static class DIExtensions
|
public static class DIExtensions
|
||||||
{
|
{
|
||||||
public static IServiceCollection AddWorkFlowRepositories(this IServiceCollection services) => services
|
public static IServiceCollection AddWorkFlowRepositories(this IServiceCollection services)
|
||||||
.AddScoped<IConfigRepository, ConfigRepository>()
|
{
|
||||||
.AddScoped<IProfileControlsTFRepository, ProfileControlsTFRepository>()
|
services.TryAddScoped<IConfigRepository, ConfigRepository>();
|
||||||
.AddScoped<IProfileObjStateRepository, ProfileObjStateRepository>()
|
services.TryAddScoped<IProfileControlsTFRepository, ProfileControlsTFRepository>();
|
||||||
.AddScoped<IProfileRepository, ProfileRepository>()
|
services.TryAddScoped<IProfileObjStateRepository, ProfileObjStateRepository>();
|
||||||
.AddScoped<IStateRepository, StateRepository>();
|
services.TryAddScoped<IProfileRepository, ProfileRepository>();
|
||||||
|
services.TryAddScoped<IStateRepository, StateRepository>();
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user