@@ -13,85 +13,52 @@ public class Occurence
1313 public static TriggerBuilder MakeTriggerBuilder ( AbstractCommand command )
1414 {
1515 if ( command == null )
16- throw new ArgumentNullException ( command . GetType ( ) . Name , "The command to schedule cannot be null. " ) ;
16+ throw new ArgumentNullException ( nameof ( command ) , "The command to schedule cannot be null" ) ;
1717 return TriggerBuilder
1818 . Create ( )
1919 . WithIdentity ( $ "{ command . Name } :job:{ command . ScheduleId } ", command . SchedulerGroup ) ;
2020 }
2121
22- public ScheduleLifeCycleBuilder RegisterJob ( Action < DailyTimeIntervalScheduleBuilder > action )
23- {
24- return new ScheduleLifeCycleBuilder {
25- JobRegistration = Schedule . RegisterJob ( Command , JobDetail , MakeTriggerBuilder ( Command ) . WithDailyTimeIntervalSchedule ( action ) . Build ( ) )
22+ public ScheduleLifeCycleBuilder RegisterJob ( Action < DailyTimeIntervalScheduleBuilder > action ) =>
23+ new ScheduleLifeCycleBuilder
24+ {
25+ JobRegistration = Schedule . RegisterJob ( Command , JobDetail ,
26+ MakeTriggerBuilder ( Command ) . WithDailyTimeIntervalSchedule ( action ) . Build ( ) )
2627 } ;
27- }
2828
29- public ScheduleLifeCycleBuilder RegisterJob ( string cronExpression )
30- {
31- return new ScheduleLifeCycleBuilder {
32- JobRegistration = Schedule . RegisterJob ( Command , JobDetail , MakeTriggerBuilder ( Command ) . WithCronSchedule ( cronExpression ) . Build ( ) )
29+ public ScheduleLifeCycleBuilder RegisterJob ( string cronExpression ) =>
30+ new ScheduleLifeCycleBuilder
31+ {
32+ JobRegistration = Schedule . RegisterJob ( Command , JobDetail ,
33+ MakeTriggerBuilder ( Command ) . WithCronSchedule ( cronExpression ) . Build ( ) )
3334 } ;
34- }
3535
36- public ScheduleLifeCycleBuilder RegisterJob ( Action < SimpleScheduleBuilder > action )
37- {
38- return new ScheduleLifeCycleBuilder {
39- JobRegistration = Schedule . RegisterJob ( Command , JobDetail , MakeTriggerBuilder ( Command ) . WithSimpleSchedule ( action ) . Build ( ) )
36+ public ScheduleLifeCycleBuilder RegisterJob ( Action < SimpleScheduleBuilder > action ) =>
37+ new ScheduleLifeCycleBuilder
38+ {
39+ JobRegistration = Schedule . RegisterJob ( Command , JobDetail ,
40+ MakeTriggerBuilder ( Command ) . WithSimpleSchedule ( action ) . Build ( ) )
4041 } ;
41- }
42-
43- public ScheduleLifeCycleBuilder Cron ( string cronExpression )
44- {
45- return RegisterJob ( cronExpression ) ;
46- }
47-
48- public ScheduleLifeCycleBuilder EverySecond ( )
49- {
50- return RegisterJob ( x => x . WithIntervalInSeconds ( 1 ) . RepeatForever ( ) ) ;
51- }
52-
53- public ScheduleLifeCycleBuilder EveryMinute ( )
54- {
55- return RegisterJob ( x => x . WithIntervalInMinutes ( 1 ) . RepeatForever ( ) ) ;
56- }
57-
58- public ScheduleLifeCycleBuilder EveryFiveMinutes ( )
59- {
60- return RegisterJob ( x => x . WithIntervalInMinutes ( 5 ) . RepeatForever ( ) ) ;
61- }
6242
63- public ScheduleLifeCycleBuilder EveryTenMinutes ( )
64- {
65- return RegisterJob ( x => x . WithIntervalInMinutes ( 10 ) . RepeatForever ( ) ) ;
66- }
43+ public ScheduleLifeCycleBuilder Cron ( string cronExpression ) => RegisterJob ( cronExpression ) ;
44+ public ScheduleLifeCycleBuilder EverySecond ( ) => RegisterJob ( x => x . WithIntervalInSeconds ( 1 ) . RepeatForever ( ) ) ;
45+ public ScheduleLifeCycleBuilder EveryMinute ( ) => RegisterJob ( x => x . WithIntervalInMinutes ( 1 ) . RepeatForever ( ) ) ;
46+ public ScheduleLifeCycleBuilder EveryFiveMinutes ( ) => RegisterJob ( x => x . WithIntervalInMinutes ( 5 ) . RepeatForever ( ) ) ;
47+ public ScheduleLifeCycleBuilder EveryTenMinutes ( ) => RegisterJob ( x => x . WithIntervalInMinutes ( 10 ) . RepeatForever ( ) ) ;
6748
68- public ScheduleLifeCycleBuilder EveryFifteenMinutes ( )
69- {
70- return RegisterJob ( x => x . WithIntervalInMinutes ( 15 ) . RepeatForever ( ) ) ;
71- }
49+ public ScheduleLifeCycleBuilder EveryFifteenMinutes ( ) =>
50+ RegisterJob ( x => x . WithIntervalInMinutes ( 15 ) . RepeatForever ( ) ) ;
7251
73- public ScheduleLifeCycleBuilder EveryThirtyMinutes ( )
74- {
75- return RegisterJob ( x => x . WithIntervalInMinutes ( 30 ) . RepeatForever ( ) ) ;
76- }
52+ public ScheduleLifeCycleBuilder EveryThirtyMinutes ( ) =>
53+ RegisterJob ( x => x . WithIntervalInMinutes ( 30 ) . RepeatForever ( ) ) ;
7754
78- public ScheduleLifeCycleBuilder Hourly ( )
79- {
80- return RegisterJob ( x => x . WithIntervalInHours ( 1 ) . RepeatForever ( ) ) ;
81- }
55+ public ScheduleLifeCycleBuilder Hourly ( ) => RegisterJob ( x => x . WithIntervalInHours ( 1 ) . RepeatForever ( ) ) ;
8256
83- public ScheduleLifeCycleBuilder HourlyAt ( int minutesAfterTheHour )
84- {
85- return RegisterJob ( $ "0 { minutesAfterTheHour } * * * ?") ;
86- }
57+ public ScheduleLifeCycleBuilder HourlyAt ( int minutesAfterTheHour ) =>
58+ RegisterJob ( $ "0 { minutesAfterTheHour } * * * ?") ;
8759
88- public ScheduleLifeCycleBuilder Daily ( )
89- {
90- return RegisterJob ( x => x . WithIntervalInHours ( 24 ) . RepeatForever ( ) ) ;
91- }
60+ public ScheduleLifeCycleBuilder Daily ( ) => RegisterJob ( x => x . WithIntervalInHours ( 24 ) . RepeatForever ( ) ) ;
9261
93- public ScheduleLifeCycleBuilder DailyAt ( int hours , int minutes , int seconds = 0 )
94- {
95- return RegisterJob ( x => x . StartingDailyAt ( new TimeOfDay ( hours , minutes , seconds ) ) ) ;
96- }
62+ public ScheduleLifeCycleBuilder DailyAt ( int hours , int minutes , int seconds = 0 ) =>
63+ RegisterJob ( x => x . StartingDailyAt ( new TimeOfDay ( hours , minutes , seconds ) ) ) ;
9764}
0 commit comments