• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Binders.MetaObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Dynamic.Binders.MetaObject的典型用法代码示例。如果您正苦于以下问题:C# MetaObject类的具体用法?C# MetaObject怎么用?C# MetaObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MetaObject类属于System.Dynamic.Binders命名空间,在下文中一共展示了MetaObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: BindInvokeMember

        public override MetaObject BindInvokeMember(InvokeMemberBinder binder, MetaObject[] args) {
            ContractUtils.RequiresNotNull(binder, "binder");

            if (args.Any(arg => ComBinderHelpers.IsStrongBoxArg(arg))) {
                return ComBinderHelpers.RewriteStrongBoxAsRef(binder, this, args);
            }

            ComMethodDesc methodDesc;

            if (_wrapperType.Funcs.TryGetValue(binder.Name, out methodDesc) ||
                  _self.TryGetMemberMethodExplicit(binder.Name, out methodDesc)) {
                return new ComInvokeBinder(
                    binder.Arguments,
                    args,
                    IDispatchRestriction(),
                    Expression.Constant(methodDesc),
                    Expression.Property(
                        Expression.Convert(Expression, typeof(IDispatchComObject)),
                        typeof(IDispatchComObject).GetProperty("DispatchObject")
                    ),
                    methodDesc
                ).Invoke();
            }

            return base.BindInvokeMember(binder, args);
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:26,代码来源:IDispatchMetaObject.cs


示例2: Bind

        public sealed override MetaObject Bind(MetaObject target, MetaObject[] args) {
            ContractUtils.RequiresNotNull(target, "target");
            ContractUtils.RequiresNotNullItems(args, "args");
            ContractUtils.Requires(args.Length == 1);

            return target.BindSetMember(this, args[0]);
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:7,代码来源:SetMemberBinder.cs


示例3: BindingTarget

 /// <summary>
 /// Creates a new BindingTarget when the method binding has succeeded
 /// </summary>
 internal BindingTarget(string name, int actualArgumentCount, MethodTarget target, NarrowingLevel level, MetaObject[] restrictedArgs) {
     _name = name;
     _target = target;
     _restrictedArgs = restrictedArgs;
     _level = level;
     _actualArgs = actualArgumentCount;
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:10,代码来源:BindingTarget.cs


示例4: TryBindInvokeMember

 public static bool TryBindInvokeMember(InvokeMemberBinder binder, ref MetaObject instance, MetaObject[] args) {
     if (TryGetMetaObject(ref instance)) {
         instance = instance.BindInvokeMember(binder, args);
         return true;
     }
     return false;
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:7,代码来源:ComBinder.cs


示例5: TryBindSetIndex

 public static bool TryBindSetIndex(SetIndexBinder binder, ref MetaObject instance, MetaObject[] args, MetaObject value) {
     if (TryGetMetaObject(ref instance)) {
         instance = instance.BindSetIndex(binder, args, value);
         return true;
     }
     return false;
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:7,代码来源:ComBinder.cs


示例6: TryBindSetMember

 public static bool TryBindSetMember(SetMemberBinder binder, ref MetaObject instance, MetaObject value) {
     if (TryGetMetaObject(ref instance)) {
         instance = instance.BindSetMember(binder, value);
         return true;
     }
     return false;
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:7,代码来源:ComBinder.cs


示例7: Bind

        public sealed override Expression Bind(object[] args, ReadOnlyCollection<ParameterExpression> parameters, LabelTarget returnLabel) {
            if (args.Length == 0) {
                throw new InvalidOperationException();
            }

            MetaObject[] mos;
            if (args.Length != 1) {
                mos = new MetaObject[args.Length - 1];
                for (int i = 1; i < args.Length; i++) {
                    mos[i - 1] = MetaObject.ObjectToMetaObject(args[i], parameters[i]);
                }
            } else {
                mos = MetaObject.EmptyMetaObjects;
            }

            MetaObject binding = Bind(
                MetaObject.ObjectToMetaObject(args[0], parameters[0]),
                mos
            );

            if (binding == null) {
                throw Error.BindingCannotBeNull();
            }

            return GetMetaObjectRule(binding, returnLabel);
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:26,代码来源:MetaObjectBinder.cs


示例8: GetArguments

        private MetaObject[] GetArguments(MetaObject[] args, IList<MetaObject> results, int metaBinderIndex) {
            BinderMappingInfo indices = _metaBinders[metaBinderIndex];

            MetaObject[] res = new MetaObject[indices.MappingInfo.Count];
            for (int i = 0; i < res.Length; i++) {
                ParameterMappingInfo mappingInfo = indices.MappingInfo[i];

                if (mappingInfo.IsAction) {
                    // input is the result of a previous bind
                    res[i] = results[mappingInfo.ActionIndex];
                } else if (mappingInfo.IsParameter) {
                    // input is one of the original arguments
                    res[i] = args[mappingInfo.ParameterIndex];
                } else {
                    // input is a constant
                    res[i] = new MetaObject(
                        mappingInfo.Constant,
                        Restrictions.Empty,
                        mappingInfo.Constant.Value
                    );
                }
            }

            return res;
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:25,代码来源:ComboBinder.cs


示例9: GetMember

 /// <summary>
 /// Builds a MetaObject for performing a member get.  Supports all built-in .NET members, the OperatorMethod 
 /// GetBoundMember, and StrongBox instances.
 /// </summary>
 /// <param name="name">
 /// The name of the member to retrieve.  This name is not processed by the DefaultBinder and
 /// is instead handed off to the GetMember API which can do name mangling, case insensitive lookups, etc...
 /// </param>
 /// <param name="target">
 /// The MetaObject from which the member is retrieved.
 /// </param>
 /// <param name="codeContext">
 /// An expression which provides access to the CodeContext if its required for 
 /// accessing the member (e.g. for an extension property which takes CodeContext).  By default this
 /// a null CodeContext object is passed.
 /// </param>
 public MetaObject GetMember(string name, MetaObject target, Expression codeContext) {
     return GetMember(
         name,
         target,
         codeContext,
         false
     );
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:24,代码来源:DefaultBinder.GetMember.cs


示例10: FallbackGetMember

        public override MetaObject/*!*/ FallbackGetMember(MetaObject/*!*/ self, MetaObject/*!*/ onBindingError) {
            var result = TryBind(_context, this, self);
            if (result != null) {
                return result; 
            }

            // TODO: remove CodeContext
            return ((DefaultBinder)_context.Binder).GetMember(Name, self, Ast.Constant(null, typeof(CodeContext)), true);
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:9,代码来源:RubyGetMemberBinder.cs


示例11: BindSetIndex

 public override MetaObject BindSetIndex(SetIndexBinder binder, MetaObject[] indexes, MetaObject value) {
     if (_callable.ComMethodDesc.IsPropertyPut) {
         if (indexes.Any(arg => ComBinderHelpers.IsStrongBoxArg(arg))) {
             return ComBinderHelpers.RewriteStrongBoxAsRef(binder, this, indexes.AddLast(value));
         }
         return BindComInvoke(binder.Arguments, indexes.AddLast(value));
     }
     return base.BindSetIndex(binder, indexes, value);
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:9,代码来源:DispCallableMetaObject.cs


示例12: FallbackInvokeMember

        public override MetaObject/*!*/ FallbackInvokeMember(MetaObject/*!*/ self, MetaObject/*!*/[]/*!*/ args, MetaObject/*!*/ onBindingError) {
            var result = TryBind(_context, this, self, args);
            if (result != null) {
                return result;
            }

            // TODO: return ((DefaultBinder)_context.Binder).GetMember(Name, self, Ast.Null(typeof(CodeContext)), true);
            throw new NotImplementedException();
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:9,代码来源:RubyInvokeMemberBinder.cs


示例13: TryAssignableConversion

        /// <summary>
        /// Checks if the conversion can be handled by a simple cast.
        /// </summary>
        private static MetaObject TryAssignableConversion(Type toType, Type type, Restrictions restrictions, MetaObject arg) {
            if (toType.IsAssignableFrom(type) ||
                (type == typeof(Null) && (toType.IsClass || toType.IsInterface))) {
                // MakeSimpleConversionTarget handles the ConversionResultKind check
                return MakeSimpleConversionTarget(toType, restrictions, arg);
            }

            return null;
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:12,代码来源:DefaultBinder.Conversions.cs


示例14: TryAllConversions

 /// <summary>
 /// Checks if any conversions are available and if so builds the target for that conversion.
 /// </summary>
 private MetaObject TryAllConversions(Type toType, ConversionResultKind kind, Type knownType, Restrictions restrictions, MetaObject arg) {
     return
         TryAssignableConversion(toType, knownType, restrictions, arg) ??           // known type -> known type
         TryExtensibleConversion(toType, knownType, restrictions, arg) ??           // Extensible<T> -> Extensible<T>.Value
         TryUserDefinedConversion(kind, toType, knownType, restrictions, arg) ??    // op_Implicit
         TryImplicitNumericConversion(toType, knownType, restrictions, arg) ??      // op_Implicit
         TryNullableConversion(toType, kind, knownType, restrictions, arg) ??       // null -> Nullable<T> or T -> Nullable<T>
         TryNullConversion(toType, knownType, restrictions);                        // null -> reference type
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:12,代码来源:DefaultBinder.Conversions.cs


示例15: DeleteMember

        /// <summary>
        /// Builds a MetaObject for performing a member delete.  Supports all built-in .NET members, the OperatorMethod 
        /// DeleteMember, and StrongBox instances.
        /// </summary>
        public MetaObject DeleteMember(string name, MetaObject target) {
            ContractUtils.RequiresNotNull(name, "name");
            ContractUtils.RequiresNotNull(target, "target");

            return DeleteMember(
                name,
                target,
                Ast.Constant(null, typeof(CodeContext))
            );
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:14,代码来源:DefaultBinder.DeleteMember.cs


示例16: FallbackCreateInstance

        public override MetaObject/*!*/ FallbackCreateInstance(MetaObject/*!*/ target, MetaObject/*!*/[]/*!*/ args, MetaObject errorSuggestion) {
            var result = TryBind(_context, this, target, args);
            if (result != null) {
                return result;
            }

            throw new NotImplementedException();
            // TODO:
            //return ((DefaultBinder)_context.Binder).Create(.GetMember(Name, self, Ast.Null(typeof(CodeContext)), true);
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:10,代码来源:RubyCreateInstanceBinder.cs


示例17: TryConvertToObject

 /// <summary>
 /// Checks if the conversion is to object and produces a target if it is.
 /// </summary>
 private static MetaObject TryConvertToObject(Type toType, Type knownType, MetaObject arg) {
     if (toType == typeof(object)) {
         if (knownType.IsValueType) {
             return MakeBoxingTarget(arg);
         } else {
             return arg;
         }
     }
     return null;
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:13,代码来源:DefaultBinder.Conversions.cs


示例18: MakeComparisonRule

 private MetaObject MakeComparisonRule(OperatorInfo info, Expression codeContext, MetaObject[] args) {
     return
         TryComparisonMethod(info, codeContext, args[0], args) ??   // check the first type if it has an applicable method
         TryComparisonMethod(info, codeContext, args[0], args) ??   // then check the second type
         TryNumericComparison(info, args) ??           // try Compare: cmp(x,y) (>, <, >=, <=, ==, !=) 0
         TryInvertedComparison(info, args[0], args) ?? // try inverting the operator & result (e.g. if looking for Equals try NotEquals, LessThan for GreaterThan)...
         TryInvertedComparison(info, args[0], args) ?? // inverted binding on the 2nd type
         TryNullComparisonRule(args) ??                // see if we're comparing to null w/ an object ref or a Nullable<T>
         TryPrimitiveCompare(info, args) ??            // see if this is a primitive type where we're comparing the two values.
         MakeOperatorError(info, args);                // no comparisons are possible            
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:11,代码来源:DefaultBinder.Operations.cs


示例19: MakeDefaultMemberRule

        /// <summary>
        /// Creates the MetaObject for indexing directly into arrays or indexing into objects which have
        /// default members.  Returns null if we're not an indexing operation.
        /// </summary>
        private MetaObject MakeDefaultMemberRule(string oper, MetaObject[] args) {
            if (oper == StandardOperators.GetItem || oper == StandardOperators.SetItem) {
                if (args[0].LimitType.IsArray) {
                    return MakeArrayIndexRule(oper, args);
                }

                return MakeMethodIndexRule(oper, args);
            }

            return null;
        }
开发者ID:mscottford,项目名称:ironruby,代码行数:15,代码来源:DefaultBinder.Operations.cs


示例20: BindCreateInstance

 public override MetaObject BindCreateInstance(CreateInstanceBinder binder, MetaObject[] args) {
     return new MetaObject(
         Expression.Call(
             AstUtils.Convert(Expression, typeof(ComTypeClassDesc)),
             typeof(ComTypeClassDesc).GetMethod("CreateInstance")
         ),
         Restrictions.Combine(args).Merge(
             Restrictions.GetTypeRestriction(Expression, typeof(ComTypeClassDesc))
         )
     );
 }
开发者ID:mscottford,项目名称:ironruby,代码行数:11,代码来源:ComClassMetaObject.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Globalization.Calendar类代码示例发布时间:2022-05-26
下一篇:
C# Dynamic.SetMemberBinder类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap