Esempio n. 1
0
 public TriggerResult(string triggerName, TransitionContext context, bool canTrigger)
 {
     TriggerName     = triggerName;
     _triggerContext = context;
     CanTrigger      = canTrigger;
     IsAborted       = _triggerContext.TransitionAborted;
     Errors          = _triggerContext.Errors;
 }
Esempio n. 2
0
 /// <summary>
 /// Returns the workflow variable from the TransitionContext.
 /// </summary>
 /// <typeparam name="TVariable"></typeparam>
 /// <param name="transitionContext"></param>
 /// <returns></returns>
 public static TVariable ReturnVariable <TVariable>(
     this TransitionContext transitionContext
     ) where TVariable : WorkflowVariableBase
 {
     return(transitionContext.GetVariable <TVariable>(
                KeyBuilder.ToKey(typeof(TVariable))
                ));
 }
Esempio n. 3
0
        private static TriggerResult CreateTriggerResult(
            string triggerName,
            TransitionContext context,
            Transition transition)
        {
            var canTrigger = transition != null && transition.CanMakeTransition(context);

            return(new TriggerResult(triggerName, context, canTrigger));
        }
Esempio n. 4
0
        private static TransitionContext CreateTransitionContext(
            IWorkflow instance,
            Dictionary <string, WorkflowVariableBase> variables)
        {
            var context = new TransitionContext(instance);

            if (variables != null)
            {
                foreach (var variable in variables)
                {
                    context.SetVariable(variable.Key, variable.Value);
                }
            }

            return(context);
        }
Esempio n. 5
0
        private TriggerResult CanMakeTransition(
            TransitionContext context,
            string triggerName,
            IWorkflow instance)
        {
            var transition    = GetTransition(triggerName, instance);
            var triggerResult = CreateTriggerResult(triggerName, context, transition);

            if (transition != null)
            {
                return(triggerResult);
            }

            context.AddError($"Transition for trigger '{triggerName}' not found!");

            return(triggerResult);
        }
Esempio n. 6
0
 /// <summary>
 /// Checks whether the workflow variable is present in the TransitionContext.
 /// </summary>
 /// <typeparam name="TVariable"></typeparam>
 /// <param name="transitionContext"></param>
 /// <returns></returns>
 public static bool HasVariable <TVariable>(
     this TransitionContext transitionContext
     )
 {
     return(transitionContext.ContainsKey(KeyBuilder.ToKey(typeof(TVariable))));
 }