Repository navigation
Expand file tree
/
Copy pathDependencyInjectionConfiguration.cs
More file actions
85 lines (77 loc) · 3.6 KB
/
Copy pathDependencyInjectionConfiguration.cs
File metadata and controls
85 lines (77 loc) · 3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using Agencias.Infra.CrossCutting.IoC;
using Avaliacoes.Infra.CrossCutting.IoC;
using Core.Domain.CommandHandlers;
using Core.Domain.Interfaces;
using Core.Domain.Notifications;
using Core.Infra.AmazonS3.Interfaces;
using Core.Infra.AmazonS3.Services;
using Core.Infra.AmazonS3.Utils;
using Core.Infra.Apple.Interfaces;
using Core.Infra.Apple.Services;
using Core.Infra.Email.Interfaces;
using Core.Infra.Email.Services;
using Core.Infra.Facebook.Interfaces;
using Core.Infra.Facebook.Services;
using Core.Infra.Google.Interfaces;
using Core.Infra.Google.Services;
using Core.Infra.PagarMe.Interfaces;
using Core.Infra.PagarMe.Services;
using Ingressos.Infra.CrossCutting.IoC;
using Localizacoes.Infra.CrossCutting.IoC;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Passeios.Infra.CrossCutting.IoC;
using Solicitacoes.Infra.CrossCutting.IoC;
using Tokens.Infra.CrossCutting.IoC;
using Transferencias.CrossCutting.IoC;
using Trivelum.API.Models;
using Turistas.Infra.CrossCutting.IoC;
using Turmas.Infra.CrossCutting.IoC;
using Viagens.Infra.CrossCutting.IoC;
namespace Trivelum.API.Configurations
{
public static class DependencyInjectionConfiguration
{
public static void AddDependencyInjectionConfiguration(this IServiceCollection services, IConfiguration configuration)
{
// ASPNET
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
// Domain Bus (Mediator)
services.AddScoped<IMediatorHandler, MediatorHandler>();
services.AddScoped<INotificationHandler<DomainNotification>, DomainNotificationHandler>();
// Infra - Identity
services.AddScoped<IUsuario, AspNetUser>();
if (EmailPelaAWSSES(configuration))
services.AddScoped<IEmailService, AmazonSESService>();
else
services.AddScoped<IEmailService, EmailService>();
// Infra - Services CrossCutting
services.AddScoped<IS3Service, S3Service>();
services.AddScoped<IFacebookService, FacebookService>();
services.AddScoped<IGoogleService, GoogleService>();
services.AddScoped<IAppleService, AppleService>();
services.AddScoped<IPagarMeService, PagarMeService>();
// Infra - Parametros de imagens
var parametrosDeImagem = new ParametrosDeImagem();
configuration.Bind("parametrosDeImagens", parametrosDeImagem);
services.AddSingleton(parametrosDeImagem);
BootstrapperLocalizacoes.RegisterServices(services);
BootstrapperTuristas.RegisterServices(services);
BootstrapperAgencias.RegisterServices(services);
BootstrapperPasseios.RegisterServices(services);
BootstrapperViagens.RegisterServices(services);
BootstrapperTurmas.RegisterServices(services);
BootstrapperIngressos.RegisterServices(services);
BootstrapperTransferencias.RegisterServices(services);
BootstrapperAvaliacoes.RegisterServices(services);
BootstrapperTokens.RegisterServices(services);
BootstrapperSolicitacoes.RegisterServices(services);
}
private static bool EmailPelaAWSSES(IConfiguration configuration) =>
!string.IsNullOrEmpty(configuration["configuracoesEmail:serverAwsSES:emailRemetente"]) &&
!string.IsNullOrEmpty(configuration["configuracoesEmail:serverAwsSES:keyID"]) &&
!string.IsNullOrEmpty(configuration["configuracoesEmail:serverAwsSES:keySecret"]);
}
}