Пример #1
0
        internal 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));
        }
Пример #2
0
 private void EnsureWorkflowVariables(Workflow workflow, TriggerParam param)
 {
     if (workflow.WorkflowVariables.Count > 0)
     {
         foreach (var workflowVariable in workflow.WorkflowVariables)
         {
             var type                 = KeyBuilder.FromKey(workflowVariable.Type);
             var variable             = JsonConvert.DeserializeObject(workflowVariable.Content, type);
             var workflowVariableBase = variable as WorkflowVariableBase;
             if (workflowVariableBase != null)
             {
                 var key = KeyBuilder.ToKey(type);
                 if (param.Variables.ContainsKey(key))
                 {
                     param.Variables[key] = variable as WorkflowVariableBase;
                 }
                 else
                 {
                     param.Variables.Add(key, variable as WorkflowVariableBase);
                 }
             }
         }
     }
 }
Пример #3
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))));
 }