Пример #1
0
        /// <summary>
        /// Registers an action to configure the <see cref="SweetAlertService"/> and add it as a singleton to the specified <see cref="IServiceCollection"/>.
        /// </summary>
        /// <param name="services">The <see cref="IServiceCollection"/> to add the <see cref="SweetAlertService"/> to.</param>
        /// <param name="configureOptions">The action used to configure the options.</param>
        /// <returns></returns>
        public static IServiceCollection AddSweetAlert2(this IServiceCollection services, Action <SweetAlertServiceOptions> configureOptions)
        {
            var options = new SweetAlertServiceOptions();

            configureOptions(options);
            return(services.AddSingleton(s => new SweetAlertService(s.GetRequiredService <IJSRuntime>(), options)));
        }
Пример #2
0
 public SweetAlertService(IJSRuntime jSRuntime, SweetAlertServiceOptions options)
 {
     this.jSRuntime          = jSRuntime;
     this.jSInProcessRuntime = jSRuntime as IJSInProcessRuntime;
     if (options.Theme != SweetAlertTheme.Default)
     {
         SetTheme(options.Theme);
     }
 }