コード例 #1
0
 /// <summary>
 /// Initializes a new <see cref="V1WorkflowActivity"/>
 /// </summary>
 /// <param name="workflowInstance">The <see cref="V1WorkflowInstance"/> the <see cref="V1WorkflowActivity"/> belongs to</param>
 /// <param name="type">The <see cref="V1WorkflowActivity"/>'s type</param>
 /// <param name="input">The <see cref="V1WorkflowActivity"/>'s data</param>
 /// <param name="metadata">The <see cref="V1WorkflowActivity"/>'s metadata</param>
 /// <param name="parent">The <see cref="V1WorkflowActivity"/>'s parent, if any</param>
 public V1WorkflowActivity(V1WorkflowInstance workflowInstance, V1WorkflowActivityType type, object?input = null, IDictionary <string, string>?metadata = null, V1WorkflowActivity?parent = null)
     : this()
 {
     if (workflowInstance == null)
     {
         throw DomainException.ArgumentNull(nameof(workflowInstance));
     }
     this.On(this.RegisterEvent(new V1WorkflowActivityCreatedDomainEvent(Guid.NewGuid().ToString(), workflowInstance.Id, type, input, metadata, parent?.Id)));
 }
コード例 #2
0
 /// <summary>
 /// Initializes a new <see cref="V1Workflow"/>
 /// </summary>
 /// <param name="definition">The <see cref="V1Workflow"/>'s definition</param>
 public V1Workflow(WorkflowDefinition definition)
     : this()
 {
     if (definition == null)
     {
         throw DomainException.ArgumentNull(nameof(definition));
     }
     this.On(this.RegisterEvent(new V1WorkflowCreatedDomainEvent(definition.GetUniqueIdentifier(), definition)));
 }
コード例 #3
0
 /// <summary>
 /// Initializes a new <see cref="V1CorrelationCondition"/>
 /// </summary>
 public V1CorrelationCondition(params V1EventFilter[] filters)
 {
     if (filters == null)
     {
         throw DomainException.ArgumentNull(nameof(filters));
     }
     if (!filters.Any())
     {
         throw DomainException.ArgumentMustHaveMinimumLengthOf(nameof(filters), 1);
     }
     this._Filters = filters.ToList();
 }
コード例 #4
0
 /// <summary>
 /// Faults the <see cref="V1WorkflowActivity"/>
 /// </summary>
 /// <param name="error">The unhandled <see cref="Error"/> that caused the <see cref="V1WorkflowActivity"/> to end prematurily</param>
 public virtual void Fault(Neuroglia.Error error)
 {
     if (error == null)
     {
         throw DomainException.ArgumentNull(nameof(error));
     }
     if (this.Status >= V1WorkflowActivityStatus.Faulted)
     {
         throw DomainException.UnexpectedState(typeof(V1WorkflowActivity), this.Id, this.Status);
     }
     this.On(this.RegisterEvent(new V1WorkflowActivityFaultedDomainEvent(this.Id, error)));
 }
コード例 #5
0
 /// <summary>
 /// Faults the <see cref="V1WorkflowActivity"/>
 /// </summary>
 /// <param name="ex">The unhandled <see cref="Exception"/> that caused the <see cref="V1WorkflowActivity"/> to end prematurily</param>
 public virtual void Fault(Exception ex)
 {
     if (ex == null)
     {
         throw DomainException.ArgumentNull(nameof(ex));
     }
     if (this.Status >= V1WorkflowActivityStatus.Faulted)
     {
         throw DomainException.UnexpectedState(typeof(V1WorkflowActivity), this.Id, this.Status);
     }
     this.Fault(new Neuroglia.Error(ex.GetType().Name.Replace("exception", string.Empty, StringComparison.OrdinalIgnoreCase), ex.Message));
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new <see cref="V1Correlation"/>
 /// </summary>
 /// <param name="lifetime">The <see cref="V1Correlation"/>'s lifetime</param>
 /// <param name="conditionType">A value determining the type of the <see cref="V1Correlation"/>'s <see cref="V1CorrelationCondition"/> evaluation</param>
 /// <param name="conditions">An <see cref="IReadOnlyCollection{T}"/> containing the <see cref="V1Correlation"/>'s conditions</param>
 /// <param name="outcome">The outcome of the <see cref="V1Correlation"/></param>
 /// <param name="context">The initial <see cref="V1CorrelationContext"/></param>
 public V1Correlation(V1CorrelationLifetime lifetime, V1CorrelationConditionType conditionType, IEnumerable <V1CorrelationCondition> conditions, V1CorrelationOutcome outcome, V1CorrelationContext?context = null)
     : base(Guid.NewGuid().ToString())
 {
     if (conditions == null ||
         !conditions.Any())
     {
         throw DomainException.ArgumentNull(nameof(conditions));
     }
     if (outcome == null)
     {
         throw DomainException.ArgumentNull(nameof(outcome));
     }
     this.On(this.RegisterEvent(new V1CorrelationCreatedDomainEvent(this.Id, lifetime, conditionType, conditions, outcome, context)));
 }
コード例 #7
0
 /// <summary>
 /// Initializes a new <see cref="V1WorkflowInstance"/>
 /// </summary>
 /// <param name="key">The <see cref="V1WorkflowInstance"/>'s key</param>
 /// <param name="workflow">The <see cref="V1WorkflowInstance"/>'s <see cref="V1Workflow"/></param>
 /// <param name="activationType">The <see cref="V1WorkflowInstance"/>'s activation type</param>
 /// <param name="input">The <see cref="V1WorkflowInstance"/>'s input data</param>
 /// <param name="correlationContext">An <see cref="IEnumerable{T}"/> containing the <see cref="CloudEvent"/>s that have triggered the creation of the <see cref="V1WorkflowInstance"/></param>
 /// <param name="parent">The <see cref="V1WorkflowInstance"/>'s parent, if any</param>
 public V1WorkflowInstance(string key, V1Workflow workflow, V1WorkflowInstanceActivationType activationType, object?input = null, V1CorrelationContext?correlationContext = null, V1WorkflowInstance?parent = null)
     : this()
 {
     if (workflow == null)
     {
         throw DomainException.ArgumentNull(nameof(workflow));
     }
     if (input == null)
     {
         input = new();
     }
     if (correlationContext == null)
     {
         correlationContext = new();
     }
     this.On(this.RegisterEvent(new V1WorkflowInstanceCreatedDomainEvent(BuildUniqueIdentifier(key, workflow), workflow.Id, key.ToLowerInvariant(), activationType, input, correlationContext, parent?.Id)));
 }