Hangfire.States.ScheduledState.Handler.Apply C# (CSharp) Method

Apply() public method

public Apply ( Hangfire.States.ApplyStateContext context, IWriteOnlyTransaction transaction ) : void
context Hangfire.States.ApplyStateContext
transaction IWriteOnlyTransaction
return void
            public void Apply(ApplyStateContext context, IWriteOnlyTransaction transaction)
            {
                var scheduledState = context.NewState as ScheduledState;
                if (scheduledState == null)
                {
                    throw new InvalidOperationException(String.Format(
                        "`{0}` state handler can be registered only for the Scheduled state.",
                        typeof(Handler).FullName));
                }

                var timestamp = JobHelper.ToTimestamp(scheduledState.EnqueueAt);
                transaction.AddToSet("schedule", context.JobId, timestamp);
            }

Usage Example

        public void Apply_ShouldAddTheJob_ToTheScheduleSet_WithTheCorrectScore()
        {
            var handler = new ScheduledState.Handler();
            handler.Apply(_context.Object, _transaction.Object);

            _transaction.Verify(x => x.AddToSet(
                "schedule", JobId, JobHelper.ToTimestamp(_enqueueAt)));
        }
All Usage Examples Of Hangfire.States.ScheduledState.Handler::Apply
ScheduledState.Handler