示例#1
0
        /// <summary>
        /// action :
        ///     key LEFT_PAREN arguments? RIGHT_PAREN
        ///     ;
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override object VisitAction([NotNull] WorkflowParser.ActionContext context)
        {
            var act = new ResultActionConfig()
            {
                Name = (string)VisitKey(context.key()),
            };

            if (!this._actions.TryGetValue(act.Name, out MethodReference method))
            {
                throw new InvalidMethodReferenceException(act.Name);
            }

            Dictionary <string, Type> o = method.Arguments.ToList().ToDictionary(c => c.Key, c => c.Value);

            var args = context.arguments();

            if (args != null)
            {
                var a = (List <(string, string)>)VisitArguments(args);
                foreach ((string, string)item in a)
                {
                    var type = ResolveTypeOfArgument(item.Item1, method);
                    var func = GetLambda(item.Item1, item.Item2, type);

                    act.Arguments.Add(item.Item1, func);
                    if (!o.ContainsKey(item.Item1))
                    {
                        if (!method.Arguments.ContainsKey(item.Item1))
                        {
                            throw new DuplicatedArgumentNameMethodReferenceException(item.Item1);
                        }
                    }
                    o.Remove(item.Item1);
                }

                if (o.Count > 0)
                {
                    throw new MissingArgumentNameMethodReferenceException(string.Join(", ", o));
                }
            }

            return(act);
        }
 /// <summary>
 /// Visit a parse tree produced by <see cref="WorkflowParser.action"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitAction([NotNull] WorkflowParser.ActionContext context)
 {
     return(VisitChildren(context));
 }
 /// <summary>
 /// action :
 ///     key LEFT_PAREN arguments? RIGHT_PAREN
 ///     ;
 /// </summary>
 /// <param name="context"></param>
 /// <returns></returns>
 public override object VisitAction([NotNull] WorkflowParser.ActionContext context)
 {
     return(base.VisitAction(context));
 }