/// <summary> /// Adds a new hosted service with options and the action to perform /// </summary> /// <typeparam name="THostedService"></typeparam> /// <typeparam name="THostedServiceOptions"></typeparam> /// <typeparam name="THostedServiceOptionsSetup"></typeparam> /// <typeparam name="TScheduledAction"></typeparam> /// <param name="builder"></param> /// <param name="configure"></param> /// <returns></returns> public static IPunctualBuilder Add <THostedService, THostedServiceOptions, THostedServiceOptionsSetup, TScheduledAction>(this IPunctualBuilder builder, Action <THostedServiceOptions> configure) where THostedService : class, IHostedService <TScheduledAction> where THostedServiceOptions : class, IHostedServiceOptions where THostedServiceOptionsSetup : class, IConfigureOptions <THostedServiceOptions> where TScheduledAction : class, IScheduledAction { if (configure == null) { throw new ArgumentNullException(nameof(configure)); } builder.Add <THostedService, THostedServiceOptions, THostedServiceOptionsSetup, TScheduledAction>(); builder.Services.Configure(configure); return(builder); }
/// <summary> /// Adds a hosted service that will perform actions on a weekly schedule /// </summary> /// <typeparam name="TScheduledAction"></typeparam> /// <param name="builder"></param> /// <returns></returns> public static IPunctualBuilder AddWeekly <TScheduledAction>(this IPunctualBuilder builder) where TScheduledAction : class, IScheduledAction { return(builder.Add <WeeklyHostedService <TScheduledAction>, WeeklyHostedServiceOptions <TScheduledAction>, WeeklyHostedServiceOptionsSetup <TScheduledAction>, TScheduledAction>()); }