internal NativeEvaluator EvaluateCallArgs(string actionName, NativeAction action, IEnumerable <string> parameters, IEnumerable <ParameterEvaluator> evaluators)
        {
            var actionId = NativeActionPrefix + actionName;

            _nativeActions.Add(actionId, action);

            AddSpanElement(actionId);

            return(e =>
            {
                var evaluatedConstraints = new Constraints();
                foreach (var parameter in parameters.Zip(evaluators, Tuple.Create))
                {
                    var evaluatedParameter = parameter.Item2(e, parameter.Item1);
                    if (evaluatedParameter == null)
                    {
                        return null;
                    }

                    evaluatedConstraints = evaluatedConstraints.AddValue(parameter.Item1, evaluatedParameter);
                }

                return SemanticItem.From(e.Item.Question, actionId, evaluatedConstraints);
            });
        }
Exemple #2
0
        private SemanticItem encodeCall(string nativeActionId, List <Tuple <string, SemanticItem> > evaluatedValues)
        {
            var arguments = new Constraints();

            foreach (var value in evaluatedValues)
            {
                arguments = arguments.AddValue(value.Item1, value.Item2);
            }

            return(SemanticItem.Entity(nativeActionId).WithConstraints(arguments));
        }