public static Type[] Match(string match) { var results = new HashSet <Type>(); Type[] types; var asms = AssemblyHandler.Assemblies; for (var i = 0; i < asms.Length; ++i) { types = AssemblyHandler.GetTypeCache(asms[i]).Types; Match(match, types, results); } types = AssemblyHandler.GetTypeCache(Core.Assembly).Types; Match(match, types, results); if (results.Count == 0) { return(Array.Empty <Type>()); } var finalResults = new Type[results.Count]; var index = 0; foreach (var t in results) { finalResults[index++] = t; } Array.Sort(finalResults, TypeNameComparer.Instance); return(finalResults); }
private static void ProcessTypes() { m_Factions = new List <Faction>(); m_Towns = new List <Town>(); Assembly[] asms = AssemblyHandler.Assemblies; for (int i = 0; i < asms.Length; ++i) { Assembly asm = asms[i]; TypeCache tc = AssemblyHandler.GetTypeCache(asm); Type[] types = tc.Types.ToArray(); for (int j = 0; j < types.Length; ++j) { Type type = types[j]; if (type.IsSubclassOf(typeof(Faction))) { if (Construct(type) is Faction faction) { Faction.Factions.Add(faction); } } else if (type.IsSubclassOf(typeof(Town))) { if (Construct(type) is Town town) { Town.Towns.Add(town); } } } } }
public static List <Type> Match(string match) { var results = new List <Type>(); Type[] types; var asms = AssemblyHandler.Assemblies; for (var i = 0; i < asms.Length; ++i) { types = AssemblyHandler.GetTypeCache(asms[i]).Types.ToArray(); Match(match, types, results); } types = AssemblyHandler.GetTypeCache(Core.Assembly).Types.ToArray(); Match(match, types, results); results.Sort(new TypeNameComparer()); return(results); }