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


C# MethodGroupExpr.VerifyArgumentsCompat方法代码示例

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


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

示例1: VerifyApplicability

		// <summary>
		//  Verifies whether the invocation arguments are compatible with the
		//  delegate's target method
		// </summary>
		public static bool VerifyApplicability (ResolveContext ec, Type delegate_type, ref Arguments args, Location loc)
		{
			int arg_count;

			if (args == null)
				arg_count = 0;
			else
				arg_count = args.Count;

			MethodBase mb = GetInvokeMethod (ec.Compiler, ec.CurrentType, delegate_type);
			MethodGroupExpr me = new MethodGroupExpr (new MemberInfo [] { mb }, delegate_type, loc);
			
			AParametersCollection pd = TypeManager.GetParameterData (mb);

			int pd_count = pd.Count;

			bool params_method = pd.HasParams;
			bool is_params_applicable = false;
			bool is_applicable = me.IsApplicable (ec, ref args, arg_count, ref mb, ref is_params_applicable) == 0;
			if (args != null)
				arg_count = args.Count;

			if (!is_applicable && !params_method && arg_count != pd_count) {
				ec.Report.Error (1593, loc, "Delegate `{0}' does not take `{1}' arguments",
					TypeManager.CSharpName (delegate_type), arg_count.ToString ());
				return false;
			}

			return me.VerifyArgumentsCompat (
					ec, ref args, arg_count, mb, 
					is_params_applicable || (!is_applicable && params_method),
					false, loc);
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:37,代码来源:delegate.cs

示例2: DoResolve

        protected override Expression DoResolve(ResolveContext ec)
        {
            if (InstanceExpr is EventExpr) {
                ((EventExpr) InstanceExpr).Error_CannotAssign (ec);
                return null;
            }

            TypeSpec del_type = InstanceExpr.Type;
            if (del_type == null)
                return null;

            method = Delegate.GetInvokeMethod (ec.Compiler, del_type);
            var mb = method;
            var me = new MethodGroupExpr (mb, del_type, loc);
            me.InstanceExpression = InstanceExpr;

            AParametersCollection pd = mb.Parameters;
            int pd_count = pd.Count;

            int arg_count = arguments == null ? 0 : arguments.Count;

            bool params_method = pd.HasParams;
            bool is_params_applicable = false;
            bool is_applicable = me.IsApplicable (ec, ref arguments, arg_count, ref mb, ref is_params_applicable) == 0;
            if (arguments != null)
                arg_count = arguments.Count;

            if (!is_applicable && !params_method && arg_count != pd_count) {
                ec.Report.Error (1593, loc, "Delegate `{0}' does not take `{1}' arguments",
                    TypeManager.CSharpName (del_type), arg_count.ToString ());
            } else if (arguments == null || !arguments.HasDynamic) {
                me.VerifyArgumentsCompat (ec, ref arguments, arg_count, mb,
                    is_params_applicable || (!is_applicable && params_method), false, loc);
            }

            type = method.ReturnType;
            eclass = ExprClass.Value;
            return this;
        }
开发者ID:speier,项目名称:shake,代码行数:39,代码来源:delegate.cs


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