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


C# Binder.SelectMethod方法代码示例

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


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

示例1: GetConstructorImpl

		internal static ConstructorInfo GetConstructorImpl (ConstructorInfo[] methods, BindingFlags bindingAttr,
								       Binder binder,
								       CallingConventions callConvention,
								       Type[] types,
								       ParameterModifier[] modifiers)
		{
			if (bindingAttr == BindingFlags.Default)
				bindingAttr = BindingFlags.Public | BindingFlags.Instance;

			ConstructorInfo found = null;
			MethodBase[] match;
			int count = 0;
			foreach (ConstructorInfo m in methods) {
				// Under MS.NET, Standard|HasThis matches Standard...
				if (callConvention != CallingConventions.Any && ((m.CallingConvention & callConvention) != callConvention))
					continue;
				found = m;
				count++;
			}
			if (count == 0)
				return null;
			if (types == null) {
				if (count > 1)
					throw new AmbiguousMatchException ();
				return (ConstructorInfo) CheckMethodSecurity (found);
			}
			match = new MethodBase [count];
			if (count == 1)
				match [0] = found;
			else {
				count = 0;
				foreach (ConstructorInfo m in methods) {
					if (callConvention != CallingConventions.Any && ((m.CallingConvention & callConvention) != callConvention))
						continue;
					match [count++] = m;
				}
			}
			if (binder == null)
				binder = Binder.DefaultBinder;
			return (ConstructorInfo) CheckMethodSecurity (binder.SelectMethod (bindingAttr, match, types, modifiers));
		}
开发者ID:ramonsmits,项目名称:mono,代码行数:41,代码来源:MonoType.cs

示例2: GetConstructorImpl

		protected override ConstructorInfo GetConstructorImpl (BindingFlags bindingAttr, Binder binder,
								       CallingConventions callConvention, Type[] types,
								       ParameterModifier[] modifiers)
		{
			check_created ();

			if (created == typeof (object)) {
				/* 
				 * This happens when building corlib. Calling created.GetConstructor 
				 * would return constructors from the real mscorlib, instead of the
				 * newly built one.
				 */

				if (ctors == null)
					return null;
 
				ConstructorBuilder found = null;
				int count = 0;
			
				foreach (ConstructorBuilder cb in ctors) {
					if (callConvention != CallingConventions.Any && cb.CallingConvention != callConvention)
						continue;
					found = cb;
					count++;
				}

				if (count == 0)
					return null;
				if (types == null) {
					if (count > 1)
						throw new AmbiguousMatchException ();
					return found;
				}
				MethodBase[] match = new MethodBase [count];
				if (count == 1)
					match [0] = found;
				else {
					count = 0;
					foreach (ConstructorInfo m in ctors) {
						if (callConvention != CallingConventions.Any && m.CallingConvention != callConvention)
							continue;
						match [count++] = m;
					}
				}
				if (binder == null)
					binder = DefaultBinder;
				return (ConstructorInfo) binder.SelectMethod (bindingAttr, match,
															  types, modifiers);
			}

			return created.GetConstructor (bindingAttr, binder, 
				callConvention, types, modifiers);
		}
开发者ID:ItsVeryWindy,项目名称:mono,代码行数:53,代码来源:TypeBuilder.cs

示例3: GetMethodImpl

		protected override MethodInfo GetMethodImpl (string name, BindingFlags bindingAttr,
							     Binder binder,
							     CallingConventions callConvention,
							     Type[] types, ParameterModifier[] modifiers)
		{
			bool ignoreCase = ((bindingAttr & BindingFlags.IgnoreCase) != 0);
			MethodInfo[] methods = GetMethodsByName (name, bindingAttr, ignoreCase, this);
			MethodInfo found = null;
			MethodBase[] match;
			int count = 0;
			
			foreach (MethodInfo m in methods) {
				// Under MS.NET, Standard|HasThis matches Standard...
				if (callConvention != CallingConventions.Any && ((m.CallingConvention & callConvention) != callConvention))
					continue;
				found = m;
				count++;
			}

			if (count == 0)
				return null;
			
			if (count == 1 && types == null) 
				return (MethodInfo) CheckMethodSecurity (found);

			match = new MethodBase [count];
			if (count == 1)
				match [0] = found;
			else {
				count = 0;
				foreach (MethodInfo m in methods) {
					if (callConvention != CallingConventions.Any && ((m.CallingConvention & callConvention) != callConvention))
						continue;
					match [count++] = m;
				}
			}

			if (types == null) 
				return (MethodInfo) CheckMethodSecurity (Binder.FindMostDerivedMatch (match));

			if (binder == null)
				binder = Binder.DefaultBinder;
			
			return (MethodInfo) CheckMethodSecurity (binder.SelectMethod (bindingAttr, match, types, modifiers));
		}
开发者ID:ramonsmits,项目名称:mono,代码行数:45,代码来源:MonoType.cs

示例4: GetMethod

 public MethodInfo GetMethod(string name, BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers)
 {
     MemberInfo[] member = this.GetMember(name, bindingAttr);
     if (member.Length == 1)
     {
         return (member[0] as MethodInfo);
     }
     int num = 0;
     foreach (MemberInfo info in member)
     {
         if (info.MemberType == MemberTypes.Method)
         {
             num++;
         }
     }
     if (num == 0)
     {
         return null;
     }
     MethodInfo[] match = new MethodInfo[num];
     num = 0;
     foreach (MemberInfo info2 in member)
     {
         if (info2.MemberType == MemberTypes.Method)
         {
             match[num++] = (MethodInfo) info2;
         }
     }
     if (binder == null)
     {
         binder = JSBinder.ob;
     }
     return (MethodInfo) binder.SelectMethod(bindingAttr, match, types, modifiers);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:34,代码来源:ScriptObject.cs

示例5: GetMethodImplInternal

        internal MethodInfo GetMethodImplInternal(String name,
                                                  BindingFlags bindingAttr,
                                                  Binder binder,
                                                  CallingConventions callConvention, 
                                                  Type[] types,
                                                  ParameterModifier[] modifiers, 
                                                  bool verifyAccess)
        {       
            if (binder == null)
                binder = DefaultBinder;
            
            // If the types array is null that means we don't care about the arguments to the method, we will simply
            //  return the one that matchs or throw an argument error...
            int argCnt = (types != null) ? types.Length : -1;
            MethodBase[] meths = GetMemberMethod(name, 
                                                 bindingAttr, 
                                                 callConvention, 
                                                 types, 
                                                 argCnt,
                                                 verifyAccess);
            // at this point a proper filter with respect to BindingAttributes and calling convention already happened
            if (meths == null)
                return null;
            if (argCnt <= 0) {
                // either no args or a method with 0 args was specified
                if (meths.Length == 1)
                    return (MethodInfo) meths[0];
                else if (argCnt < 0) {
                    // There are multiple methods with the same name. Check to see if they are all
                    // new slots with the same name and sig.
                    foreach(MethodBase m in meths) {
                        if (!System.DefaultBinder.CompareMethodSigAndName(m, meths[0]))
                            // One of the methods is not a new slot. So the match is ambigous.
                            throw new AmbiguousMatchException(Environment.GetResourceString("RFLCT.Ambiguous"));
                        }

                    // All the methods are new slots with the same name and sig so return the most derived one.
                    return (MethodInfo) System.DefaultBinder.FindMostDerivedNewSlotMeth(meths, meths.Length);
                }
            }   
            
            return (MethodInfo) binder.SelectMethod(bindingAttr,meths,types,modifiers);                  
        }
开发者ID:ArildF,项目名称:masters,代码行数:43,代码来源:runtimetype.cs

示例6: GetConstructorImplInternal

     internal ConstructorInfo GetConstructorImplInternal(BindingFlags bindingAttr,
                                                         Binder binder,
                                                         CallingConventions callConvention, 
                                                         Type[] types,
                                                         ParameterModifier[] modifiers, 
                                                         bool verifyAccess)
     {
 
         // Must provide some types (Type[0] for nothing)
         if (types == null)
             throw new ArgumentNullException("types");
         
         if (binder == null)
             binder = DefaultBinder;
         
         int argCnt = types.Length;
         bool isDelegate;
         MethodBase[] cons = GetMemberCons(bindingAttr, 
                                           callConvention, 
                                           types,
                                           argCnt, 
                                           verifyAccess, 
                                           /*binder == DefaultBinder, */
                                           out isDelegate);
         if (cons == null)
             return null;
         
         if (argCnt == 0 && cons.Length == 1) { 
             ParameterInfo[] pars = cons[0].GetParameters();
             if (pars == null || pars.Length == 0) {
                 return (ConstructorInfo) cons[0];
             }
         }
         if ((bindingAttr & BindingFlags.ExactBinding) != 0)
             return (ConstructorInfo) System.DefaultBinder.ExactBinding(cons,types,modifiers);
         
         return (ConstructorInfo) binder.SelectMethod(bindingAttr,cons,types,modifiers);
     }   
开发者ID:ArildF,项目名称:masters,代码行数:38,代码来源:runtimetype.cs

示例7: GetMethod

 public MethodInfo GetMethod(String name, BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers){
   MemberInfo[] members = this.GetMember(name, bindingAttr);
   if (members.Length == 1) return members[0] as MethodInfo;
   int methodCount = 0;
   foreach (MemberInfo member in members)
     if (member.MemberType == MemberTypes.Method) methodCount++;
   if (methodCount == 0) return null;
   MethodInfo[] methods = new MethodInfo[methodCount];
   methodCount = 0;
   foreach (MemberInfo member in members)
     if (member.MemberType == MemberTypes.Method) methods[methodCount++] = (MethodInfo)member;
   if (binder == null) binder = JSBinder.ob;
   return (MethodInfo)binder.SelectMethod(bindingAttr, methods, types, modifiers);
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:14,代码来源:scriptobject.cs


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