Exemplo n.º 1
0
        public Toaster(ToasterConfiguration configuration)
        {
            Configuration           = configuration;
            Configuration.OnUpdate += ConfigurationUpdated;

            ToastLock = new ReaderWriterLockSlim();
            Toasts    = new List <Toast>();
            Version   = GetType().InformationalVersion();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a singleton <see cref="IToaster"/> instance to the DI <see cref="IServiceCollection"/> with an action for configuring the default <see cref="ToasterConfiguration"/>
        /// </summary>
        public static IServiceCollection AddToaster(this IServiceCollection services, Action <ToasterConfiguration> configure)
        {
            if (configure == null)
            {
                throw new ArgumentNullException(nameof(configure));
            }

            var options = new ToasterConfiguration();

            configure(options);

            return(AddToaster(services, options));
        }
Exemplo n.º 3
0
 public Toaster(ToasterConfiguration configuration)
 {
     Configuration           = configuration;
     Configuration.OnUpdate += ConfigurationUpdated;
     Version = GetType().InformationalVersion();
 }
Exemplo n.º 4
0
 /// <summary>
 /// Adds a singleton <see cref="IToaster"/> instance to the DI <see cref="IServiceCollection"/> with the specified <see cref="ToasterConfiguration"/>
 /// </summary>
 public static IServiceCollection AddToaster(this IServiceCollection services, ToasterConfiguration configuration)
 {
     if (configuration == null)
     {
         throw new ArgumentNullException(nameof(configuration));
     }
     services.TryAddScoped <IToaster>(builder => new Toaster(configuration));
     return(services);
 }