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


C# Binders.MetaObject类代码示例

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


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


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