本文整理汇总了C#中System.Linq.Expressions.Expression.IsMemoryLocationOrConstant方法的典型用法代码示例。如果您正苦于以下问题:C# Expression.IsMemoryLocationOrConstant方法的具体用法?C# Expression.IsMemoryLocationOrConstant怎么用?C# Expression.IsMemoryLocationOrConstant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Linq.Expressions.Expression
的用法示例。
在下文中一共展示了Expression.IsMemoryLocationOrConstant方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateExpression
private Expression GenerateExpression(Expression left, Expression right) {
Contract.Requires(left != null);
Contract.Requires(right != null);
Contract.Requires(left.IsMemoryLocationOrConstant());
Contract.Requires(right.IsMemoryLocationOrConstant());
Contract.Ensures(Contract.Result<Expression>() != null);
return Condition(
ReductionExpressionGenerator.GenerateOrThrow("GREATEREQUAL", left, right),
left,
right
);
}
示例2: CreateExpression
private Expression CreateExpression(Expression input) {
Contract.Requires(null != input);
Contract.Requires(input.IsMemoryLocationOrConstant());
Contract.Ensures(Contract.Result<Expression>() != null);
var gen = ReductionExpressionGenerator;
var one = gen.GenerateOrThrow("1", input.Type);
var log = gen.GenerateOrThrow("LOG",
gen.GenerateOrThrow("DIVIDE",
gen.GenerateOrThrow("ADD", one, input),
gen.GenerateOrThrow("SUBTRACT", one, input)
)
);
var two = gen.GenerateOrThrow("2", input.Type);
return gen.GenerateOrThrow("DIVIDE", log, two);
}
示例3: CreateExpression
private Expression CreateExpression(Expression input) {
Contract.Requires(input != null);
Contract.Requires(input.IsMemoryLocationOrConstant());
Contract.Ensures(Contract.Result<Expression>() != null);
var gen = ReductionExpressionGenerator;
return gen.GenerateOrThrow("LOG",
gen.GenerateOrThrow("ADD",
gen.GenerateOrThrow("SQUAREROOT",
gen.GenerateOrThrow("ADD",
gen.GenerateOrThrow("SQUARE", input),
gen.GenerateOrThrow("1", input.Type)
)
),
input
)
);
}
示例4: GenerateCompareTo
private Expression GenerateCompareTo(IExpressionGenerationRequest request, Expression left, Expression right) {
Contract.Requires(null != request);
Contract.Requires(null != left);
Contract.Requires(null != right);
if (left.IsMemoryLocationOrConstant() && right.IsMemoryLocationOrConstant()) {
var eq = request.TopLevelGenerator.GenerateOrThrow("EQUAL", left, right);
var less = request.TopLevelGenerator.GenerateOrThrow("LESS", left, right);
Contract.Assume(typeof(IComparable<>).GetGenericArguments() != null);
Contract.Assume(typeof(IComparable<>).GetGenericArguments().Length == 1);
Contract.Assume(typeof(IComparable<>).IsGenericTypeDefinition());
var comparableType = typeof(IComparable<>).MakeGenericType(right.Type);
if (left.Type.ImplementsInterface(comparableType)) {
var method = comparableType.GetPublicInstanceInvokableMethod(
"CompareTo",
new[] {right.Type}
);
Contract.Assume(method != null);
return method.BuildInstanceCallExpression(left, right);
}
return Expression.Condition(
eq,
Expression.Constant(0),
Expression.Condition(
less,
Expression.Constant(-1),
Expression.Constant(1)
)
);
}
return new BlockExpressionBuilder().AddUsingMemoryLocationsOrConstants(locals => new[] {
GenerateCompareTo(request, locals[0], locals[1])
}, left, right).GetExpression();
}