本文整理汇总了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());
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}
示例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));
}