Exemplo n.º 1
0
 public static InitializationOnEventConfig AddSwitch(this InitializationOnEventConfig self, string targetStateName, Func <RunContext, bool> rule = null, string ruleName = "", string code = "", RuleSpan whenRulePosition = null)
 {
     self.AddSwitch(new InitializationConfig()
     {
         TargetStateName = targetStateName, WhenRule = rule, WhenRuleText = ruleName, WhenRuleCode = code, WhenRulePosition = whenRulePosition
     });
     return(self);
 }
Exemplo n.º 2
0
        public static WorkflowConfig AddFilter(this WorkflowConfig self, string eventName, string targetStateName, Func <RunContext, bool> rule)
        {
            if (!self.Initializers.TryGetValue(eventName, out InitializationOnEventConfig o))
            {
                self.Initializers.Add(eventName, o = new InitializationOnEventConfig()
                {
                    EventName = eventName
                });
            }

            o.Switchs.Add(new InitializationConfig()
            {
                TargetStateName = targetStateName, WhenRule = rule
            });

            return(self);
        }
Exemplo n.º 3
0
        /// <summary>
        /// initializing_item :
        ///     ON EVENT key (WHEN rule_conditions)? RECURSIVE? SWITCH key
        ///     ;
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override object VisitInitializing_item([NotNull] WorkflowParser.Initializing_itemContext context)
        {
            var    keys      = context.key();
            string eventName = (string)VisitKey(keys[0]);
            string _switch   = (string)VisitKey(keys[1]);

            string conditionTxt          = string.Empty;
            string conditionCode         = string.Empty;
            Func <RunContext, bool> func = null;
            RuleSpan whenRulePosition    = null;

            if (context.WHEN() != null)
            {
                var condition = context.rule_conditions();
                conditionTxt = condition.GetText();
                var compilation = ((Func <RunContext, bool>, string))Compile((ExpressionModel)VisitRule_conditions(condition));
                func             = compilation.Item1;
                conditionCode    = compilation.Item2;
                whenRulePosition = new RuleSpan()
                {
                    StartLine   = condition.Start.Line,
                    StartColumn = condition.Start.Column,
                    StartIndex  = condition.Start.StartIndex,

                    StopLine   = condition.Stop.Line,
                    StopColumn = condition.Stop.Column,
                    StopIndex  = condition.Stop.StopIndex,
                };
            }

            InitializationOnEventConfig c1 = new InitializationOnEventConfig()
            {
                EventName = eventName,
                Recursive = context.RECURSIVE() != null,
            }
            .AddSwitch(_switch, func, conditionTxt, conditionCode, whenRulePosition);

            return(c1);
        }
Exemplo n.º 4
0
 public static WorkflowConfig AddInitializer(this WorkflowConfig self, InitializationOnEventConfig initializer)
 {
     self.Initializers.Add(initializer.EventName, initializer);
     return(self);
 }
Exemplo n.º 5
0
 public static InitializationOnEventConfig AddSwitch(this InitializationOnEventConfig self, InitializationConfig @switch)
 {
     self.Switchs.Add(@switch);
     return(self);
 }