Exemplo n.º 1
0
        public static IServiceCollection AddScheduledTask <TScheduledTask>(
            this IServiceCollection services,
            System.Action <IScheduledTaskOptions <TScheduledTask> > configureOptions
            )
            where TScheduledTask : class, IScheduledTask
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }
            if (configureOptions == null)
            {
                throw new ArgumentNullException(nameof(configureOptions));
            }

            var options = new ScheduledTaskOptions <TScheduledTask>();

            configureOptions.Invoke(options);
            return(services.AddService <TScheduledTask>(options));
        }
Exemplo n.º 2
0
        public static IScheduledTaskOptions <TScheduledTask> AddScheduledTaskOptions <TScheduledTask>(
            this IServiceCollection services,
            IConfiguration configuration
            )
            where TScheduledTask : class, IScheduledTask
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            var options = new ScheduledTaskOptions <TScheduledTask>();

            configuration.Bind(options);
            services.AddScheduledTaskOptions(options);
            return(options);
        }