本文整理汇总了C#中Expression.Reduce方法的典型用法代码示例。如果您正苦于以下问题:C# Expression.Reduce方法的具体用法?C# Expression.Reduce怎么用?C# Expression.Reduce使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Expression
的用法示例。
在下文中一共展示了Expression.Reduce方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Reduce
public Money Reduce(Expression source, string targetCurrency)
{
if (source is Money)
return (Money)source.Reduce(this, targetCurrency);
Sum sum = (Sum)source;
return sum.Reduce(this, targetCurrency);
}
示例2: Reduce
public Money Reduce(Expression source, string to)
{
return source.Reduce(this, to);
}
示例3: TransformAndDynamicConvert
internal MSAst.Expression TransformAndDynamicConvert(Expression expression, Type/*!*/ type) {
Debug.Assert(expression != null);
MSAst.Expression res = expression;
// Do we need conversion?
if (!CanAssign(type, expression.Type)) {
// ensure we're reduced before we check for dynamic expressions.
var reduced = expression.Reduce();
if (reduced is LightDynamicExpression) {
reduced = reduced.Reduce();
}
// Add conversion step to the AST
MSAst.DynamicExpression ae = reduced as MSAst.DynamicExpression;
ReducableDynamicExpression rde = reduced as ReducableDynamicExpression;
if ((ae != null && ae.Binder is PythonBinaryOperationBinder) ||
(rde != null && rde.Binder is PythonBinaryOperationBinder)) {
// create a combo site which does the conversion
PythonBinaryOperationBinder binder;
IList<MSAst.Expression> args;
if (ae != null) {
binder = (PythonBinaryOperationBinder)ae.Binder;
args = ArrayUtils.ToArray(ae.Arguments);
} else {
binder = (PythonBinaryOperationBinder)rde.Binder;
args = rde.Args;
}
ParameterMappingInfo[] infos = new ParameterMappingInfo[args.Count];
for (int i = 0; i < infos.Length; i++) {
infos[i] = ParameterMappingInfo.Parameter(i);
}
res = Expression.Dynamic(
GlobalParent.PyContext.BinaryOperationRetType(
binder,
GlobalParent.PyContext.Convert(
type,
ConversionResultKind.ExplicitCast
)
),
type,
args
);
} else {
res = GlobalParent.Convert(
type,
ConversionResultKind.ExplicitCast,
reduced
);
}
}
return res;
}