/// <summary> /// Initialize the behavior and the decorated operation. /// </summary> /// <param name="configuration">The configruation for the current /// workflow</param> public void Initialize(WorkflowConfiguration configuration) { Verify.NotNull(configuration, nameof(configuration)); _logger = configuration.Logger; InnerOperation.Initialize(configuration); }
private void ExecuteCompensatingOperation() { BehaviorWasApplied("Executing compensating operation"); var context = OperationContext.Create(InnerOperation.GetInnermostOperation()); context.ProvideInputs(_operation); _operation.Execute(); }
/// <summary> /// Register the application of a behavior. Use this when the behavior causes the normal /// execution flow to be abandoned, documenting what happened. Behavior that has no impact /// on the execution should not be registered. /// </summary> /// <param name="description">A text describing how the workflow was modified by the behavior</param> protected void BehaviorWasApplied(string description) { Verify.NotNull(description, nameof(description)); _logger?.BehaviorWasApplied(InnerOperation.GetInnermostOperation(), this, description); }
/// <summary> /// Get child operations for the decorated operation. The behavior has a chance to /// perform special logic before or after retreiving the operations. /// </summary> /// <returns></returns> public virtual IEnumerable <IOperation> GetChildOperations() => InnerOperation.GetChildOperations();
/// <summary> /// Execute the behavior. The behavior has a chance to apply special logic before /// or after invoking the Execute method on the inner operation. /// </summary> public virtual void Execute() => InnerOperation.Execute();
private bool HasExecutedNonIdempotentChildOperations() { return(InnerOperation.GetExecutedChildOperationsForOperationHierarchy().Any(o => !IsIdempotent(o.Operation))); }
private bool Log(Exception e) { _logger.OperationFailed(InnerOperation.GetInnermostOperation(), e); return(false); }