当前位置: 首页>>代码示例>>C#>>正文


C# IToken.EvaluateList方法代码示例

本文整理汇总了C#中IToken.EvaluateList方法的典型用法代码示例。如果您正苦于以下问题:C# IToken.EvaluateList方法的具体用法?C# IToken.EvaluateList怎么用?C# IToken.EvaluateList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IToken的用法示例。


在下文中一共展示了IToken.EvaluateList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Evaluate

        public override IToken Evaluate(IToken first, IToken last, TokenTreeList parameters, bool isFinal)
        {
            if (_function == null)
            {
                if (first == null)
                    throw new Exception($"Operation {Text} can not be unary.");

                IToken functionToken = first.Evaluate(parameters, isFinal);
                if (functionToken == null || functionToken is ListToken)
                    throw new Exception($"First element of Operation {Text} is not unique.");

                string function = functionToken.Text;
                switch (function)
                {
                    case AndFunction.ID:
                        _function = new AndFunction();
                        break;
                    case AggregateFunction.ID:
                        _function = new AggregateFunction();
                        break;
                    case CaseFunction.ID:
                        _function = new CaseFunction();
                        break;
                    case ComparisonFunction.ID:
                        _function = new ComparisonFunction();
                        break;
                    case ContainsFunction.ID:
                        _function = new ContainsFunction();
                        break;
                    case CountFunction.ID:
                        _function = new CountFunction();
                        break;
                    case DoubleFunction.ID:
                        _function = new DoubleFunction();
                        break;
                    case IfFunction.ID:
                        _function = new IfFunction();
                        break;
                    case IntFunction.ID:
                        _function = new IntFunction();
                        break;
                    case JoinFunction.ID:
                        _function = new JoinFunction();
                        break;
                    case OrFunction.ID:
                        _function = new OrFunction();
                        break;
                    case OverFunction.ID:
                        _function = new OverFunction();
                        break;
                    case RangeFunction.ID:
                        _function = new RangeFunction();
                        break;
                    case RegexFunction.ID:
                        _function = new RegexFunction();
                        break;
                    case ReverseFunction.ID:
                        _function = new ReverseFunction();
                        break;
                    case SplitFunction.ID:
                        _function = new SplitFunction();
                        break;
                    case SumFunction.ID:
                        _function = new SumFunction();
                        break;
                    case UserFunction.ID:
                        _function = new UserFunction();
                        break;
                    default:
                        ListToken newList = new ListToken
                        {
                            new ExpressionToken(null, new SubstitutionOperator(), new StringToken(function))
                        };
                        ListToken oldList = last.Evaluate(parameters, isFinal) as ListToken;
                        if (oldList != null)
                        {
                            foreach (IToken token in oldList.Tokens)
                                newList.Add(token);
                        }
                        else
                        {
                            newList.Add(last);
                        }
                        ExpressionToken expression = new ExpressionToken(null, new FunctionOperator(new UserFunction()), newList);
                        return expression.Evaluate(parameters, isFinal);
                }
            }

            IToken parameterList;
            if (isFinal && _function is UserFunction)
            {
                parameterList = PrepareUserFunction(last, parameters);
            }
            else if (_function.IsComparisonFunction)
            {
                parameterList = last.EvaluateList();
            }
            else
            {
                parameterList = last.Evaluate(parameters, !_function.FinalCanBeExpression && isFinal);
//.........这里部分代码省略.........
开发者ID:MotorViper,项目名称:FormGenerator,代码行数:101,代码来源:FunctionOperator.cs


注:本文中的IToken.EvaluateList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。