public static void AddNotyf(this IServiceCollection services, Action <NotyfConfig> configure)
        {
            var configurationValue = new NotyfConfig();

            configure(configurationValue);
            var options = new NotyfEntity(configurationValue.DurationInSeconds, configurationValue.Position, configurationValue.IsDismissable);

            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            services.AddFrameworkServices();

            //Add TempDataWrapper for accessing and adding values to tempdata.
            services.AddSingleton <ITempDataService, TempDataService>();
            // Add MessageContainerFactory for creating MessageContainer instance
            services.AddSingleton <IMessageContainerFactory, MessageContainerFactory>();
            //services.AddSingleton<IToastNotificationContainer<NotyfNotification>, TempDataToastNotificationContainer<NotyfNotification>>();
            //services.AddSingleton<IToastNotificationContainer<NotyfNotification>, InMemoryNotificationContainer<NotyfNotification>>();
            //Add the ToastNotification implementation
            services.AddScoped <INotyfService, NotyfService>();
            //Middleware
            services.AddScoped <NotyfMiddleware>();
            services.AddSingleton(options);
        }
Exemplo n.º 2
0
 public NotyfViewComponent(INotyfService service, NotyfEntity options)
 {
     this._service = service;
     _options      = options;
 }
 public NotyfMiddleware(INotyfService toastNotification, ILogger <NotyfMiddleware> logger, NotyfEntity options)
 {
     _toastNotification = toastNotification;
     _logger            = logger;
     _options           = options;
 }