/// <summary>
        /// Configure Emeraude framework required services and functionalities.
        /// </summary>
        /// <typeparam name="TContextInterface">Interface of the application database context.</typeparam>
        /// <typeparam name="TContextImplementation">Implementation of the application database context.</typeparam>
        /// <param name="services"></param>
        /// <param name="optionsAction"></param>
        /// <returns></returns>
        public static EmeraudeSettingsBuilder AddEmeraude <TContextInterface, TContextImplementation>(
            this IServiceCollection services,
            Action <EmOptions> optionsAction = null)
            where TContextInterface : class, IEmContext
            where TContextImplementation : EmContext <TContextImplementation>, TContextInterface
        {
            var settingsBuilder = new EmeraudeSettingsBuilder
            {
                Services = services,
            };

            var options = new EmOptions();

            optionsAction?.Invoke(options);

            var applicationAssembly = Assembly.GetCallingAssembly().GetName().Name;
            var serviceProvider     = services.BuildServiceProvider();
            var configuration       = serviceProvider.GetService <IConfiguration>();

            services.RegisterEmeraudeOptions(optionsAction);

            services.AddHttpContextAccessor();

            services.ConfigureDatabases <TContextInterface, TContextImplementation>(configuration, options);

            services.ConfigureMapper(applicationAssembly, options.Mapping);

            services.ConfigureIdentityOptions <TContextImplementation>();

            services.ConfigureRazorViews();

            settingsBuilder.AuthenticationBuilder = services.AddEmeraudeAuthentication(options.Account);

            services.ConfigureGoogleReCaptcha();

            services.LoadSmtpOptions();

            services.RegisterEmeraudeIdentity();

            services.RegisterEmeraudeLogger(configuration, options);

            services.RegisterEmeraudeLocalization(options);

            services.RegisterEmailInfrastructure(options.GetExternalOption <EmEmailOptions>());

            services.RegisterEmeraudeSystemFilesManagement(options.GetExternalOption <EmFilesOptions>());

            services.ConfigureAuthorizationPolicies();

            services.AddEmeraudeAdmin();

            services.AddEmeraudeClient();

            services.AddDefinuxSeo(options.GetExternalOption <Action <DefinuxSeoOptions> >());

            services.RegisterMediatR(options.Assemblies);

            services.AddCqrsBehaviours();

            services.AddDatabaseInitializer <IApplicationDatabaseInitializer, ApplicationDatabaseInitializer>();

            services.RegisterHtmlOptimizationServices();

            services.ConfigureMvc(options);

            return(settingsBuilder);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Get Emeraude files infrastructure options.
 /// </summary>
 /// <param name="options"></param>
 /// <returns></returns>
 public static EmFilesOptions GetFilesOptions(this EmOptions options) => options.GetExternalOption <EmFilesOptions>() ?? new EmFilesOptions();