本文整理汇总了C#中System.Dynamic.DynamicMetaObject.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# DynamicMetaObject.Clone方法的具体用法?C# DynamicMetaObject.Clone怎么用?C# DynamicMetaObject.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Dynamic.DynamicMetaObject
的用法示例。
在下文中一共展示了DynamicMetaObject.Clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertComArgument
internal static DynamicMetaObject/*!*/ ConvertComArgument(DynamicMetaObject/*!*/ arg) {
Expression expr = arg.Expression;
BindingRestrictions restrictions;
if (arg.Value != null) {
Type type = arg.Value.GetType();
if (type == typeof(BigInteger)) {
expr = Ast.Convert(AstUtils.Convert(arg.Expression, typeof(BigInteger)), typeof(double));
} else if (type == typeof(MutableString)) {
// TODO: encoding?
expr = Ast.Convert(AstUtils.Convert(arg.Expression, typeof(MutableString)), typeof(string));
} else if (type == typeof(RubySymbol)) {
// TODO: encoding?
expr = Ast.Convert(AstUtils.Convert(arg.Expression, typeof(RubySymbol)), typeof(string));
}
restrictions = BindingRestrictions.GetTypeRestriction(arg.Expression, type);
} else {
restrictions = BindingRestrictions.GetExpressionRestriction(Ast.Equal(arg.Expression, AstUtils.Constant(null)));
}
return arg.Clone(expr, restrictions);
}
示例2: MakeOperatorSetMemberBody
/// <summary> if a member-injector is defined-on or registered-for this type call it </summary>
private bool MakeOperatorSetMemberBody(SetOrDeleteMemberInfo memInfo, DynamicMetaObject self, DynamicMetaObject target, Type type, string name) {
if (self != null) {
MethodInfo setMem = GetMethod(type, name);
if (setMem != null) {
ParameterExpression tmp = Ast.Variable(target.Expression.Type, "setValue");
memInfo.Body.AddVariable(tmp);
var callMo = MakeCallExpression(
memInfo.ResolutionFactory,
setMem,
self.Clone(AstUtils.Convert(self.Expression, type)),
new DynamicMetaObject(AstUtils.Constant(memInfo.Name), BindingRestrictions.Empty, memInfo.Name),
target.Clone(tmp)
);
var call = Ast.Block(Ast.Assign(tmp, target.Expression), callMo.Expression);
if (setMem.ReturnType == typeof(bool)) {
memInfo.Body.AddCondition(
call,
tmp
);
} else {
memInfo.Body.FinishCondition(Ast.Block(call, AstUtils.Convert(tmp, typeof(object))));
}
return setMem.ReturnType != typeof(bool);
}
}
return false;
}
示例3: FallbackConvert
public override DynamicMetaObject/*!*/ FallbackConvert(DynamicMetaObject/*!*/ target, DynamicMetaObject errorSuggestion) {
#if !SILVERLIGHT
DynamicMetaObject result;
if (Microsoft.Scripting.ComInterop.ComBinder.TryConvert(this, target, out result)) {
return result;
}
#endif
return target.Clone(Ast.NewArrayInit(typeof(object), target.Expression));
}