public MemberInfo(MemberTypes mt, TypeReference tr) { MemberType = mt; Type = tr; }
public TypeReference GetMemberType(TypeReference typeRef, string name, out MemberTypes memberType) { MemberInfo[] mi = RefTypeToType(typeRef).GetMember(name); for (int i = 0; i < mi.Length; i++) { if (mi[i] is PropertyInfo) { memberType = MemberTypes.Property; return new TypeReference(((PropertyInfo)mi[i]).PropertyType); } else if (mi[i] is FieldInfo) { memberType = MemberTypes.Field; return new TypeReference(((FieldInfo)mi[i]).FieldType); } else if (mi[i] is MethodInfo) { memberType = MemberTypes.Method; return new TypeReference(((MethodInfo)mi[i]).ReturnType); } else if (mi[i] is EventInfo) { memberType = MemberTypes.Event; return new TypeReference(((EventInfo)mi[i]).EventHandlerType); } // other types? } memberType = MemberTypes.All; return null; }
private Type RefTypeToType(TypeReference refType) { for (int i = 0; i < asmNames.Count; i++) { if (asmNames[i] == refType.Assembly) { return refs[i].GetType(refType.FullName); } } return Assembly.Load(refType.Assembly).GetType(refType.FullName); }