public static IServiceCollection AddForEvolveAspNetCore(this IServiceCollection services, EmailOptions emailOptions, Action <ForEvolveAspNetCoreSettings> setupAction = null) { var settings = new ForEvolveAspNetCoreSettings(); setupAction?.Invoke(settings); return(services.AddSingleton(emailOptions) .AddForEvolveAspNetCore(settings)); }
public static IServiceCollection AddForEvolveAspNetCore(this IServiceCollection services, IConfiguration configuration, Action <ForEvolveAspNetCoreSettings> setupAction = null) { var settings = new ForEvolveAspNetCoreSettings { Configuration = configuration }; setupAction?.Invoke(settings); return(services.AddForEvolveAspNetCore(settings)); }
/// <summary> /// Adds most ForEvolve.AspNetCore services to the specified <c>Microsoft.Extensions.DependencyInjection.IServiceCollection</c>. /// </summary> /// <param name="services">The <c>Microsoft.Extensions.DependencyInjection.IServiceCollection</c> to add the service to.</param> /// <param name="setupAction">An action used to configure the <c>ForEvolveAspNetCoreSettings</c>.</param> /// <returns>A reference to this instance after the operation has completed.</returns> public static IServiceCollection AddForEvolveAspNetCore(this IServiceCollection services, Action <ForEvolveAspNetCoreSettings> setupAction = null) { // ForEvolve.AspNetCore var settings = new ForEvolveAspNetCoreSettings(); setupAction?.Invoke(settings); return(services .InternalAddForEvolveAspNetCore(settings) // Emails .AddForEvolveEmailSender(settings) ); }
/// <summary> /// Adds the <c>IEmailSender</c> services to the specified <c>Microsoft.Extensions.DependencyInjection.IServiceCollection</c>. /// <c>EmailOptions</c> will be loaded from the the settings configuration, /// if any; otherwise, default <c>EmailOptions</c> will be used instead. /// </summary> /// <param name="services">The <c>Microsoft.Extensions.DependencyInjection.IServiceCollection</c> to add the service to.</param> /// <param name="settings"> /// The settings used to bind configurations to the <c>EmailOptions</c>. /// Make sure the Configuration and EmailOptionsConfigurationKey property are set. /// </param> /// <returns>A reference to this instance after the operation has completed.</returns> public static IServiceCollection AddForEvolveEmailSender(this IServiceCollection services, ForEvolveAspNetCoreSettings settings) { var emailOptions = new EmailOptions(); settings.Configuration?.Bind(settings.EmailOptionsConfigurationKey, emailOptions); return(services.AddForEvolveEmailSender(emailOptions)); }
private static IServiceCollection InternalAddForEvolveAspNetCore(this IServiceCollection services, ForEvolveAspNetCoreSettings settings) { services // Setup configs .AddSingleton(settings) // HttpHeaderValueAccessor .AddForEvolveHttpHeaderValueAccessor() // ViewRenderer .AddForEvolveViewRenderer() ; return(services); }
private static IServiceCollection AddForEvolveAspNetCore(this IServiceCollection services, ForEvolveAspNetCoreSettings settings) { // Setup configs services.AddSingleton(settings); // Error and OperationResults services .AddForEvolveErrorFactory() .AddForEvolveOperationResults() ; // Others services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.TryAddSingleton <IHttpRequestValueFinder, HttpRequestValueFinder>(); // Emails services.TryAddScoped <IViewRenderer, ViewRenderer>(); services.TryAddSingleton <IEmailSender, DefaultEmailSender>(); var emailOptions = new EmailOptions(); settings.Configuration?.Bind(settings.EmailOptionsConfigurationKey, emailOptions); services.TryAddSingleton(emailOptions); return(services); }