Ejemplo n.º 1
0
        public Expression Get(IToken token, Expression[] args, Expression[] contextArgs, ErrorListener errors)
        {
            string errorDetails = null;

            Type[] types = args.Select(arg => arg.Type).ToArray();

            try
            {
                BuiltinExecutor executor = this.Executors.FirstOrDefault(ex => ex.InputArgs.Match(types, ex.IsQueryValueSupported));
                // contextArgs currently are very straightforward. BodyQuery and TwinChangeIncludes use them to get message body.
                // Not doing a match on internal args to retrieve the executor as of yet

                if (executor != null)
                {
                    if (executor.IsQueryValueSupported)
                    {
                        // Wrap all args as QueryValue
                        args = WrapArgsAsQueryValue(args);
                    }

                    return(executor.ExecutorFunc(args, contextArgs));
                }
            }
            catch (Exception ex) when(!ex.IsFatal())
            {
                errorDetails = ex.Message;
            }

            errors.ArgumentError(token, this.Executors.Select(ex => ex.InputArgs).ToArray(), types, errorDetails);
            return(Expression.Constant(Undefined.Instance));
        }