public static BindCost ( |
||
arg | Expression to be converted. | |
target | Target type. | |
리턴 |
/// <summary> /// Gets expression representing cost of argument binding operation. /// The expression can be constant. /// </summary> public virtual Expression BindCostOf(int srcarg, Type ptype, bool ismandatory) { var key = new TmpVarKey() { Priority = 100, ArgIndex = srcarg, TargetTypeOpt = ptype, Prefix = "costOf" + (ismandatory ? "" : "Opt") }; // lookup cache TmpVarValue value; if (!_tmpvars.TryGetValue(key, out value)) { // bind cost expression value = new TmpVarValue(); var expr_cost = ConvertExpression.BindCost(BindArgument(srcarg), ptype); if (expr_cost is ConstantExpression) { value.Expression = expr_cost; } else { value.TrueInitializer = expr_cost; value.FalseInitializer = Expression.Constant(ismandatory ? ConversionCost.MissingArgs : ConversionCost.DefaultValue); value.Expression = Expression.Variable(typeof(ConversionCost), key.VariableName); } _tmpvars[key] = value; } // return(value.Expression); }