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


C# ExpressionBuilder.Create方法代码示例

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


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

示例1: EmptyExpression_Test

        public void EmptyExpression_Test()
        {
            ExpressionBuilder builder = new ExpressionBuilder();
            Expression<Func<bool>> expression = builder.Create<Func<bool>>("");
            Func<bool> func = expression.Compile();

            Assert.IsTrue(func());
        }
开发者ID:calexconc,项目名称:TextToCalcExpression,代码行数:8,代码来源:ParseErrorsTests.cs

示例2: EvaluateNumericalOperation2_Test

        public void EvaluateNumericalOperation2_Test()
        {
            ExpressionBuilder builder = new ExpressionBuilder();
            Expression<Func<int>> expression = builder.Create<Func<int>>("2^3");
            Func<int> func = expression.Compile();

            Assert.AreEqual(func(), 8);
        }
开发者ID:calexconc,项目名称:TextToCalcExpression,代码行数:8,代码来源:EvalTests.cs

示例3: EmptyParentesisExpression_Test

        public void EmptyParentesisExpression_Test()
        {
            ExpressionBuilder builder = new ExpressionBuilder();
            Expression<Func<int>> expression = builder.Create<Func<int>>("2+1+()-1");
            Func<int> func = expression.Compile();

            Assert.AreEqual(func(), 0);
        }
开发者ID:calexconc,项目名称:TextToCalcExpression,代码行数:8,代码来源:ParseErrorsTests.cs

示例4: EvaluateConstantValue_Test

        public void EvaluateConstantValue_Test()
        {
            ExpressionBuilder builder = new ExpressionBuilder();
            Expression<Func<double>> expression = builder.Create<Func<double>>("-PI");
            Func<double> func = expression.Compile();

            Assert.AreEqual(func(), -1*Math.PI);
        }
开发者ID:calexconc,项目名称:TextToCalcExpression,代码行数:8,代码来源:EvalTests.cs

示例5: NotEqualsTupleTrue_Test

        public void NotEqualsTupleTrue_Test()
        {
            ExpressionBuilder builder = new ExpressionBuilder();
            Expression<Func<bool,bool, bool>> expression = builder.Create<Func<bool,bool, bool>>("A != B");
            Func<bool,bool, bool> func = expression.Compile();

            Assert.IsTrue(func(false, true));
        }
开发者ID:calexconc,项目名称:TextToCalcExpression,代码行数:8,代码来源:ComparisonOperationsTests.cs

示例6: EvaluateBoolExpression2_Test

        public void EvaluateBoolExpression2_Test()
        {
            ExpressionBuilder builder = new ExpressionBuilder();
            Expression<Func<bool>> expression = builder.Create<Func<bool>>("NOT(false) AND true");
            Func<bool> func = expression.Compile();

            Assert.AreEqual(func(), true);
        }
开发者ID:calexconc,项目名称:TextToCalcExpression,代码行数:8,代码来源:EvalTests.cs

示例7: Exp_Test

        public void Exp_Test()
        {
            ExpressionBuilder builder = new ExpressionBuilder();
            Expression<Func<double,double>> expression = builder.Create<Func<double, double>>("EXP A");
            Func<double,double> func = expression.Compile();

            Assert.AreEqual(func(0), 1);
        }
开发者ID:calexconc,项目名称:TextToCalcExpression,代码行数:8,代码来源:FunctionsTests.cs

示例8: Sin_Test

        public void Sin_Test()
        {
            ExpressionBuilder builder = new ExpressionBuilder();
            Expression<Func<double,double>> expression = builder.Create<Func<double, double>>("SIN(A/2)");
            Func<double,double> func = expression.Compile();

            Assert.AreEqual(func(Math.PI), 1);
        }
开发者ID:calexconc,项目名称:TextToCalcExpression,代码行数:8,代码来源:FunctionsTests.cs

示例9: Cos_Test3

        public void Cos_Test3()
        {
            ExpressionBuilder builder = new ExpressionBuilder();
            Expression<Func<double,double>> expression = builder.Create<Func<double, double>>("-COS -A");
            Func<double,double> func = expression.Compile();

            Assert.AreEqual(func(Math.PI), 1);
        }
开发者ID:calexconc,项目名称:TextToCalcExpression,代码行数:8,代码来源:FunctionsTests.cs

示例10: EvaluateBoolValue_Test

        public void EvaluateBoolValue_Test()
        {
            ExpressionBuilder builder = new ExpressionBuilder();
            Expression<Func<bool>> expression = builder.Create<Func<bool>>("false");
            Func<bool> func = expression.Compile();

            Assert.AreEqual(func(), false);
        }
开发者ID:calexconc,项目名称:TextToCalcExpression,代码行数:8,代码来源:EvalTests.cs

示例11: TwoArgsMultiplication_Test

        public void TwoArgsMultiplication_Test()
        {
            ExpressionBuilder builder = new ExpressionBuilder();
            Expression<Func<int,int, int>> expression = builder.Create<Func<int,int, int>>("A * B");
            Func<int,int, int> func = expression.Compile();

            Assert.AreEqual(func(16, 2), 32);
        }
开发者ID:calexconc,项目名称:TextToCalcExpression,代码行数:8,代码来源:ArithmeticTests.cs

示例12: TupleAndNot_Test

        public void TupleAndNot_Test()
        {
            ExpressionBuilder builder = new ExpressionBuilder();
            Expression<Func<bool,bool, bool>> expression = builder.Create<Func<bool,bool, bool>>("A AND NOT B");
            Func<bool,bool, bool> func = expression.Compile();

            Assert.IsFalse(func(true, true));
        }
开发者ID:calexconc,项目名称:TextToCalcExpression,代码行数:8,代码来源:BooleanOperationsTests.cs

示例13: Poli3ArgsPlusConstantPlusParentesisFunction3_Test

        public void Poli3ArgsPlusConstantPlusParentesisFunction3_Test()
        {
            ExpressionBuilder builder = new ExpressionBuilder();
            Expression<Func<int,int, int,int>> expression = builder.Create<Func<int,int, int, int>>("(A + B + 1) + (B+C)*2 + 1");
            Func<int,int, int, int> func = expression.Compile();

            Assert.AreEqual(func(12, 2, -1), 18);
        }
开发者ID:calexconc,项目名称:TextToCalcExpression,代码行数:8,代码来源:ArithmeticTests.cs

示例14: Poli3ArgsPlusConstantPlusParentesisFunction_Test

        public void Poli3ArgsPlusConstantPlusParentesisFunction_Test()
        {
            ExpressionBuilder builder = new ExpressionBuilder();
            Expression<Func<int,int, int,int>> expression = builder.Create<Func<int,int, int, int>>("A * (B+C)+6");
            Func<int,int, int, int> func = expression.Compile();

            Assert.AreEqual(func(16, 2, -2), 6);
        }
开发者ID:calexconc,项目名称:TextToCalcExpression,代码行数:8,代码来源:ArithmeticTests.cs

示例15: TupleANDWithORComparisonMixedEquals_Test

        public void TupleANDWithORComparisonMixedEquals_Test()
        {
            ExpressionBuilder builder = new ExpressionBuilder();
            Expression<Func<bool,bool, bool>> expression = builder.Create<Func<bool,bool, bool>>("A==A AND A!=B OR B==B");
            Func<bool,bool, bool> func = expression.Compile();

            Assert.IsTrue(func(true, false));
        }
开发者ID:calexconc,项目名称:TextToCalcExpression,代码行数:8,代码来源:BooleanOperationsTests.cs


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