/// <summary>
 /// Initializes a new <see cref="EventStateTriggerDefinitionValidator"/>
 /// </summary>
 /// <param name="workflow">The <see cref="WorkflowDefinition"/> the <see cref="EventStateTriggerDefinition"/> to validate belongs to</param>
 /// <param name="eventState">The <see cref="EventStateDefinition"/> the <see cref="EventStateTriggerDefinition"/> to validate belongs to</param>
 public EventStateTriggerDefinitionValidator(WorkflowDefinition workflow, EventStateDefinition eventState)
 {
     this.Workflow   = workflow;
     this.EventState = eventState;
     this.RuleForEach(t => t.Actions)
     .SetValidator(new ActionDefinitionValidator(this.Workflow))
     .When(t => t.Actions != null && t.Actions.Any())
     .WithErrorCode($"{nameof(EventStateTriggerDefinition)}.{nameof(EventStateTriggerDefinition.Actions)}");
     this.RuleFor(t => t.Events)
     .NotEmpty()
     .WithErrorCode($"{nameof(EventStateTriggerDefinition)}.{nameof(EventStateTriggerDefinition.Events)}");
     this.RuleForEach(t => t.Events)
     .Must(ReferenceExistingEvent)
     .When(t => t.Events != null && t.Events.Any())
     .WithErrorCode($"{nameof(EventStateTriggerDefinition)}.{nameof(EventStateTriggerDefinition.Events)}")
     .WithMessage(eventRef => $"Failed to find an event with name '{eventRef}'");
     this.RuleForEach(t => t.Events)
     .Must(BeConsumed)
     .When(t => t.Events != null && t.Events.Any())
     .WithErrorCode($"{nameof(EventStateTriggerDefinition)}.{nameof(EventStateTriggerDefinition.Events)}")
     .WithMessage(eventRef => $"The event with name '{eventRef}' must be of kind '{EnumHelper.Stringify(EventKind.Consumed)}' to be used in an event state trigger");
 }
Beispiel #2
0
 /// <summary>
 /// Initializes a new <see cref="WorkflowActivityProcessor"/>
 /// </summary>
 /// <param name="loggerFactory">The service used to create <see cref="ILogger"/>s</param>
 /// <param name="context">The current <see cref="IWorkflowRuntimeContext"/></param>
 /// <param name="activityProcessorFactory">The service used to create <see cref="IWorkflowActivityProcessor"/>s</param>
 /// <param name="jsonSerializer">The service used to serialize/deserialize to/from JSON</param>
 /// <param name="options">The service used to access the current <see cref="ApplicationOptions"/></param>
 /// <param name="activity">The <see cref="V1WorkflowActivity"/> to process</param>
 /// <param name="state">The <see cref="EventStateDefinition"/> to process</param>
 /// <param name="trigger">The <see cref="EventStateTriggerDefinition"/> to process</param>
 public EventStateTriggerProcessor(ILoggerFactory loggerFactory, IWorkflowRuntimeContext context, IWorkflowActivityProcessorFactory activityProcessorFactory, IJsonSerializer jsonSerializer,
                                   IOptions <ApplicationOptions> options, V1WorkflowActivity activity, EventStateDefinition state, EventStateTriggerDefinition trigger)
     : base(loggerFactory, context, activityProcessorFactory, options, activity)
 {
     this.JsonSerializer = jsonSerializer;
     this.State          = state;
     this.Trigger        = trigger;
 }