本文整理匯總了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();
}