using Mono.Cecil; using Mono.Collections.Generic; namespace ReCodeItLib.Models; /// /// This is a database of type, field, property etc info collected into one place for an assembly. /// /// internal class TypeDatabaseModel { public TypeDatabaseModel(ModuleDefinition moduleDefinition) { ModuleDefinition = moduleDefinition; GetAllTypes(ModuleDefinition.Types); } public ModuleDefinition ModuleDefinition { get; private set; } public List Types { get; private set; } = []; /// /// Key, the type definition the property belongs too /// public Dictionary Properties { get; private set; } /// /// Key, the type definition the method belongs too /// public Dictionary Methods { get; private set; } /// /// Key, the type definition the field belongs too /// public Dictionary Fields { get; private set; } private void GetAllTypes(Collection types) { foreach (var type in types) { if (type.HasNestedTypes) { GetAllTypes(type.NestedTypes); } Types.Add(type); } } }