本文整理汇总了C#中IExpression.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# IExpression.Execute方法的具体用法?C# IExpression.Execute怎么用?C# IExpression.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IExpression
的用法示例。
在下文中一共展示了IExpression.Execute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Mul
/// <summary>
/// Multiplies <paramref name="vector"/> by <paramref name="number"/>.
/// </summary>
/// <param name="vector">The vector.</param>
/// <param name="number">The number.</param>
/// <param name="parameters">An object that contains all parameters and functions for expressions.</param>
/// <returns>The product of matrices.</returns>
public static Vector Mul(this Vector vector, IExpression number, ExpressionParameters parameters)
{
var n = (double)number.Execute(parameters);
var numbers = (from num in vector.Arguments.AsParallel().AsOrdered()
select new Number((double)num.Execute(parameters) * n))
.ToArray();
return new Vector(numbers);
}
示例2: Generate
public void Generate(string strExp)
{
lexer = new Lexer();
var tokens = lexer.Tokenize(strExp);
expression = parser.Parse(tokens);
if (!expression.ResultType.HasFlagNI(ExpressionResultType.Boolean))
throw new NotSupportedException();
expressions = Helpers.ConvertExpressionToCollection(expression);
parameters = Helpers.GetParameters(tokens);
table = new List<TruthTableRowViewModel>();
var parametersCount = parameters.Count();
for (int i = (int)Math.Pow(2, parametersCount) - 1; i >= 0; i--)
{
SetBits(i, parametersCount);
var b = (bool)expression.Execute(parameters);
var row = new TruthTableRowViewModel(parametersCount, expressions.Count());
row.Index = (int)Math.Pow(2, parametersCount) - i;
for (int j = 0; j < parametersCount; j++)
row.VarsValues[j] = (bool)parameters[parameters.ElementAt(j).Key];
for (int j = 0; j < expressions.Count() - 1; j++)
row.Values[j] = (bool)expressions.ElementAt(j).Execute(parameters);
if (expressions.Count() != 0)
row.Result = b;
table.Add(row);
}
}