当前位置: 首页>>代码示例>>C#>>正文


C# DynamicMetaObject.Clone方法代码示例

本文整理汇总了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);
 }
开发者ID:ExpertsInside,项目名称:IronSP,代码行数:20,代码来源:InteropBinder.cs

示例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;
        }
开发者ID:BrianGenisio,项目名称:ironruby,代码行数:33,代码来源:DefaultBinder.SetMember.cs

示例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));
            }
开发者ID:ExpertsInside,项目名称:IronSP,代码行数:9,代码来源:InteropBinder.cs


注:本文中的System.Dynamic.DynamicMetaObject.Clone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。