diff --git a/Il2CppInspector/Il2CppModel.cs b/Il2CppInspector/Il2CppModel.cs index ad62158..35c3419 100644 --- a/Il2CppInspector/Il2CppModel.cs +++ b/Il2CppInspector/Il2CppModel.cs @@ -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: diff --git a/Il2CppInspector/Reflection/TypeInfo.cs b/Il2CppInspector/Reflection/TypeInfo.cs index d9538e9..9876026 100644 --- a/Il2CppInspector/Reflection/TypeInfo.cs +++ b/Il2CppInspector/Reflection/TypeInfo.cs @@ -70,6 +70,15 @@ namespace Il2CppInspector.Reflection { public List DeclaredProperties { get; } = new List(); + // 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;