internal MethodDefinition GetConstructorInternal(bool isStatic, IList parameters) { if (parameters == null) #if CF_2_0 || CF_1_0 { parameters = new Type[0]; } #else { parameters = Type.EmptyTypes; } #endif foreach (MethodDefinition ctor in this) { if (ctor.IsStatic != isStatic || ctor.Parameters.Count != parameters.Count) { continue; } bool match = true; for (int i = 0; i < parameters.Count; i++) { string pname; object param = parameters [i]; if (param is Type) { pname = ReflectionHelper.GetTypeSignature(param as Type); } else if (param is TypeReference) { pname = (param as TypeReference).FullName; } else if (param is ParameterDefinition) { pname = (param as ParameterDefinition).ParameterType.FullName; } else { throw new NotSupportedException(); } if (ctor.Parameters [i].ParameterType.FullName != pname) { match = false; break; } } if (match) { return(ctor); } } return(null); }
public MethodDefinition GetConstructor (bool isStatic, Type [] parameters) { foreach (MethodDefinition ctor in this) { if (ctor.IsStatic == isStatic && ctor.Parameters.Count == parameters.Length) { if (parameters.Length == 0) return ctor; for (int i = 0; i < parameters.Length; i++) if (ctor.Parameters [i].ParameterType.FullName == ReflectionHelper.GetTypeSignature (parameters [i])) return ctor; } } return null; }
internal MethodDefinition GetMethodInternal(string name, IList parameters) { foreach (MethodDefinition meth in this) { if (meth.Name != name || meth.Parameters.Count != parameters.Count) { continue; } bool match = true; for (int i = 0; i < parameters.Count; i++) { string pname; object param = parameters [i]; if (param is Type) { pname = ReflectionHelper.GetTypeSignature(param as Type); } else if (param is TypeReference) { pname = (param as TypeReference).FullName; } else if (param is ParameterDefinition) { pname = (param as ParameterDefinition).ParameterType.FullName; } else { throw new NotSupportedException(); } if (meth.Parameters [i].ParameterType.FullName != pname) { match = false; break; } } if (match) { return(meth); } } return(null); }
public MethodDefinition GetMethod(string name, Type [] parameters) { foreach (MethodDefinition meth in this) { if (meth.Name == name && meth.Parameters.Count == parameters.Length) { if (parameters.Length == 0) { return(meth); } for (int i = 0; i < parameters.Length; i++) { if (meth.Parameters [i].ParameterType.FullName == ReflectionHelper.GetTypeSignature(parameters [i])) { return(meth); } } } } return(null); }