Exemple #1
0
 /// <summary>
 /// Adds a workflow variable to the TriggerParam variables collection.
 /// </summary>
 /// <typeparam name="TVariable"></typeparam>
 /// <param name="triggerParam"></param>
 /// <param name="value"></param>
 /// <returns></returns>
 public static TriggerParam AddVariableWithKey <TVariable>(
     this TriggerParam triggerParam,
     WorkflowVariableBase value
     )
 {
     return(triggerParam.AddVariable(KeyBuilder.ToKey(typeof(TVariable)), value));
 }
Exemple #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))
                ));
 }
Exemple #3
0
 public static WorkflowVariable Create(Workflow workflow, WorkflowVariableBase variable)
 {
     return(new WorkflowVariable
     {
         WorkflowId = workflow.Id,
         Workflow = workflow,
         Type = KeyBuilder.ToKey(variable.GetType()),
         Content = JsonConvert.SerializeObject(variable)
     });
 }
Exemple #4
0
        public void AddVariable(WorkflowVariableBase variable)
        {
            var type     = KeyBuilder.ToKey(variable.GetType());
            var existing = this.WorkflowVariables.FirstOrDefault(v => v.Type == type);

            if (existing != null)
            {
                existing.UpdateContent(variable);

                return;
            }

            this.WorkflowVariables.Add(WorkflowVariable.Create(this, variable));
        }
Exemple #5
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))));
 }