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


C# DynamicMetaObject.ToList方法代码示例

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


在下文中一共展示了DynamicMetaObject.ToList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ResolveOverload

        DynamicMetaObject ResolveOverload(DynamicMetaObject target, DynamicMetaObject[] args, MethodInfo[] methods, BindingRestrictions additionalRestrictions = null)
        {
            OverloadResolver or;
            if (target != null)
            {
                List<DynamicMetaObject> tmp = args.ToList();
                tmp.Insert(0, target);
                args = tmp.ToArray();
                or = this._languageContext.OverloadResolverFactory.CreateOverloadResolver(args, new CallSignature(args.Length), CallTypes.None);
            }
            else
            {
                or = this._languageContext.OverloadResolverFactory.CreateOverloadResolver(args, new CallSignature(args.Length), CallTypes.None);
            }
            BindingTarget bt = or.ResolveOverload(this.Name, methods, NarrowingLevel.None, NarrowingLevel.All);
            BindingRestrictions restrictions = bt.RestrictedArguments != null ? bt.RestrictedArguments.GetAllRestrictions() : BindingRestrictions.Empty;

            if (!bt.Success)
            {
                foreach (DynamicMetaObject mo in args)
                    restrictions = restrictions.Merge(BindingRestrictions.GetTypeRestriction(mo.Expression, mo.GetLimitType()));

                return DefaultBinder.MakeError(or.MakeInvalidParametersError(bt), restrictions, typeof(object));
            }

            if(additionalRestrictions != null)
                restrictions = restrictions.Merge(additionalRestrictions);

            Expression callExpression = bt.MakeExpression();

            if (callExpression.Type == typeof(void))
                callExpression = Expression.Block(new[] { callExpression, Expression.Constant(null) });
            else if (callExpression.Type != typeof(object))
                callExpression = Expression.Convert(callExpression, typeof(object));

            return new DynamicMetaObject(callExpression, restrictions);
        }
开发者ID:dlurton,项目名称:Happy,代码行数:37,代码来源:HappyInvokeMemberBinder.cs


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