diff --git a/WorkFlow.Application/DIExtensions.cs b/WorkFlow.Application/DIExtensions.cs new file mode 100644 index 0000000..4f48499 --- /dev/null +++ b/WorkFlow.Application/DIExtensions.cs @@ -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(); + services.TryAddScoped(); + services.TryAddScoped(); + services.TryAddScoped(); + services.TryAddScoped(); + + return services; + } + + public static IServiceCollection AddWorkFlow(this IServiceCollection services) => services.AddWorkFlowRepositories().AddWorkFlowServices(); + } +} \ No newline at end of file diff --git a/WorkFlow.Infrastructure/DIExtensions.cs b/WorkFlow.Infrastructure/DIExtensions.cs index b938b07..a7b63d5 100644 --- a/WorkFlow.Infrastructure/DIExtensions.cs +++ b/WorkFlow.Infrastructure/DIExtensions.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; using WorkFlow.Infrastructure.Contracts; using WorkFlow.Infrastructure.Repositories; @@ -6,11 +7,15 @@ namespace WorkFlow.Infrastructure { public static class DIExtensions { - public static IServiceCollection AddWorkFlowRepositories(this IServiceCollection services) => services - .AddScoped() - .AddScoped() - .AddScoped() - .AddScoped() - .AddScoped(); + public static IServiceCollection AddWorkFlowRepositories(this IServiceCollection services) + { + services.TryAddScoped(); + services.TryAddScoped(); + services.TryAddScoped(); + services.TryAddScoped(); + services.TryAddScoped(); + + return services; + } } } \ No newline at end of file