public override MethodBase SelectMethod(BindingFlags bindingAttr, MethodBase[] match, Type[] types, ParameterModifier[] modifiers)
		{
			int matchCount = 0;
			foreach (MethodBase method in match)
			{
				if (MatchParameterTypes(method.GetParameters(), types))
				{
					match[matchCount++] = method;
				}
			}

			if (matchCount == 0)
			{
				return null;
			}

			MethodBase bestMatch = match[0];
			bool ambiguous = false;
			for (int i = 1; i < matchCount; i++)
			{
				SelectBestMatch(match[i], types, ref bestMatch, ref ambiguous);
			}
			if (ambiguous)
			{
				throw new AmbiguousMatchException();
			}
			return bestMatch;
		}
Esempio n. 2
0
		public PropertyInfo GetProperty(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
		{
			PropertyInfo found = null;
			foreach (PropertyInfo prop in GetProperties(bindingAttr))
			{
				if (prop.Name == name && prop.PropertyType.Equals(returnType) && MatchParameterTypes(prop.GetIndexParameters(), types))
				{
					if (found != null)
					{
						throw new AmbiguousMatchException();
					}
					found = prop;
				}
			}
			return found;
		}
Esempio n. 3
0
		public PropertyInfo GetProperty(string name, Type returnType, Type[] types, ParameterModifier[] modifiers)
		{
			return GetProperty(name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static, null, returnType, types, modifiers);
		}
Esempio n. 4
0
		public ConstructorInfo GetConstructor(BindingFlags bindingAttr, Binder binder, CallingConventions callingConvention, Type[] types, ParameterModifier[] modifiers)
		{
			// FXBUG callConvention seems to be ignored
			return GetConstructor(bindingAttr, binder, types, modifiers);
		}
Esempio n. 5
0
		public ConstructorInfo GetConstructor(BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers)
		{
			foreach (ConstructorInfo constructor in GetConstructors(bindingAttr))
			{
				if (constructor.MethodSignature.MatchParameterTypes(types))
				{
					return constructor;
				}
			}
			return null;
		}
Esempio n. 6
0
		public MethodInfo GetMethod(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
		{
			// FXBUG callConvention seems to be ignored
			return GetMethod(name, bindingAttr, binder, types, modifiers);
		}
Esempio n. 7
0
		public MethodInfo GetMethod(string name, BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers)
		{
			MethodInfo found = null;
			foreach (MethodInfo method in GetMethods(bindingAttr))
			{
				if (method.Name == name && method.MethodSignature.MatchParameterTypes(types))
				{
					if (found != null)
					{
						throw new AmbiguousMatchException();
					}
					found = method;
				}
			}
			return found;
		}
Esempio n. 8
0
		public MethodInfo GetMethod(string name, Type[] types, ParameterModifier[] modifiers)
		{
			return GetMethod(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public, null, types, modifiers);
		}
Esempio n. 9
0
		public MethodInfo GetMethod(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)
		{
			return IsResource() ? null : GetModuleType().GetMethod(name, bindingAttr | BindingFlags.DeclaredOnly, binder, callConv, types, modifiers);
		}
Esempio n. 10
0
		public abstract PropertyInfo SelectProperty(BindingFlags bindingAttr, PropertyInfo[] match, Type returnType, Type[] indexes, ParameterModifier[] modifiers);
Esempio n. 11
0
		public abstract MethodBase SelectMethod(BindingFlags bindingAttr, MethodBase[] match, Type[] types, ParameterModifier[] modifiers);
Esempio n. 12
0
		public virtual MethodBase BindToMethod(BindingFlags bindingAttr, MethodBase[] match, ref object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] names, out object state)
		{
			throw new InvalidOperationException();
		}
Esempio n. 13
0
		public override PropertyInfo SelectProperty(BindingFlags bindingAttr, PropertyInfo[] match, Type returnType, Type[] indexes, ParameterModifier[] modifiers)
		{
			int matchCount = 0;
			foreach (PropertyInfo property in match)
			{
				if (indexes == null || MatchParameterTypes(property.GetIndexParameters(), indexes))
				{
					if (returnType != null)
					{
						if (property.PropertyType.IsPrimitive)
						{
							if (!IsAllowedPrimitiveConversion(returnType, property.PropertyType))
							{
								continue;
							}
						}
						else
						{
							if (!property.PropertyType.IsAssignableFrom(returnType))
							{
								continue;
							}
						}
					}
					match[matchCount++] = property;
				}
			}

			if (matchCount == 0)
			{
				return null;
			}

			if (matchCount == 1)
			{
				return match[0];
			}

			PropertyInfo bestMatch = match[0];
			bool ambiguous = false;
			for (int i = 1; i < matchCount; i++)
			{
				int best = MatchTypes(bestMatch.PropertyType, match[i].PropertyType, returnType);
				if (best == 0 && indexes != null)
				{
					best = MatchSignatures(bestMatch.PropertySignature, match[i].PropertySignature, indexes);
				}
				if (best == 0)
				{
					int depth1 = GetInheritanceDepth(bestMatch.DeclaringType);
					int depth2 = GetInheritanceDepth(match[i].DeclaringType);
					if (bestMatch.Name == match[i].Name && depth1 != depth2)
					{
						if (depth1 > depth2)
						{
							best = 1;
						}
						else
						{
							best = 2;
						}
					}
					else
					{
						ambiguous = true;
					}
				}
				if (best == 2)
				{
					ambiguous = false;
					bestMatch = match[i];
				}
			}
			if (ambiguous)
			{
				throw new AmbiguousMatchException();
			}
			return bestMatch;
		}
Esempio n. 14
0
File: Binder.cs Progetto: koush/mono
		public abstract MethodBase BindToMethod(BindingFlags bindingAttr, MethodBase[] match, ref object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] names, out object state);