Model: Add GetAssembly, GetType, GetMethod, GetField, GetProperty helpers

This commit is contained in:
Katy Coe
2019-11-02 17:39:50 +01:00
parent f3e9c27ae7
commit 39fafb6c94
2 changed files with 15 additions and 0 deletions

View File

@@ -44,6 +44,12 @@ namespace Il2CppInspector.Reflection
Assemblies.Add(new Assembly(this, image));
}
// Get an assembly by its name
public Assembly GetAssembly(string name) => Assemblies.First(a => a.FullName == name);
// Get a type by its full name
public TypeInfo GetType(string name) => Types.First(t => t.FullName == name);
private TypeInfo getNewTypeUsage(Il2CppType usage, MemberTypes memberType) {
switch (usage.type) {
case Il2CppTypeEnum.IL2CPP_TYPE_CLASS:

View File

@@ -70,6 +70,15 @@ namespace Il2CppInspector.Reflection {
public List<PropertyInfo> DeclaredProperties { get; } = new List<PropertyInfo>();
// Get a field by its name
public FieldInfo GetField(string name) => DeclaredFields.First(f => f.Name == name);
// Get a method by its name
public MethodInfo GetMethod(string name) => DeclaredMethods.First(m => m.Name == name);
// Get a property by its name
public PropertyInfo GetProperty(string name) => DeclaredProperties.First(p => p.Name == name);
// Method that the type is declared in if this is a type parameter of a generic method
public MethodBase DeclaringMethod;