コード例 #1
0
 /// <summary>Configures the mail template service.</summary>
 /// <param name="services">The services.</param>
 /// <param name="manager">The manager.</param>
 /// <returns></returns>
 public static IServiceCollection ConfigureMailTemplateService(this IServiceCollection services,
                                                               ValidatingConfigurationManager manager)
 {
     // configure options and validators
     manager.ConfigureValidator(new MailTemplateOptionsValidator());
     services.Configure <MailTemplateOptions>(manager, true);
     services.AddScoped <ITemplatingService, RazorLightTemplatingService>();
     return(services);
 }
コード例 #2
0
 /// <summary>Configures the mail service.</summary>
 /// <param name="services">The services.</param>
 /// <param name="manager">The manager.</param>
 /// <returns></returns>
 public static IServiceCollection ConfigureMailService(this IServiceCollection services,
                                                       ValidatingConfigurationManager manager)
 {
     // configure options and validators
     manager.ConfigureValidator(new MailServiceOptionsValidator());
     services.Configure <MailServiceOptions>(manager, true);
     services.Configure <MailServerCertificateValidationOptions>(manager, true);
     services.AddSingleton <IMailTransportFactory, MailKitSmtpTransportFactory>();
     services.AddScoped <IMailService, CertificateValidatingMailService>(provider =>
                                                                         new CertificateValidatingMailService(
                                                                             provider.GetRequiredService <IOptionsMonitor <MailServiceOptions> >(),
                                                                             provider.GetService <ILogger <CertificateValidatingMailService> >(),
                                                                             provider.GetRequiredService <IOptionsMonitor <MailServerCertificateValidationOptions> >(),
                                                                             provider.GetRequiredService <IMailTransportFactory>()));
     return(services);
 }