public static List <Type> Match(string match) { List <Type> results = new List <Type>(); Type[] types; Assembly[] asms = ScriptCompiler.Assemblies; for (int i = 0; i < asms.Length; ++i) { types = ScriptCompiler.GetTypeCache(asms[i]).Types; Match(match, types, results); } types = ScriptCompiler.GetTypeCache(Core.Assembly).Types; Match(match, types, results); results.RemoveAll(t => t == null); if (results.Count > 1) { results.Sort((l, r) => Insensitive.Compare(l.Name, r.Name)); } return(results); }
public static List <Type> Match(string match) { List <Type> results = new List <Type>(); Type[] types; Assembly[] asms = ScriptCompiler.Assemblies; for (int i = 0; i < asms.Length; ++i) { types = ScriptCompiler.GetTypeCache(asms[i]).Types; Match(match, types, results); } types = ScriptCompiler.GetTypeCache(Core.Assembly).Types; Match(match, types, results); results.Sort(new TypeNameComparer()); return(results); }
private static void ProcessTypes() { m_Factions = new List <Faction>(); m_Towns = new List <Town>(); Assembly[] asms = ScriptCompiler.Assemblies; for (int i = 0; i < asms.Length; ++i) { Assembly asm = asms[i]; TypeCache tc = ScriptCompiler.GetTypeCache(asm); Type[] types = tc.Types; for (int j = 0; j < types.Length; ++j) { Type type = types[j]; if (type.IsSubclassOf(typeof(Faction))) { Faction faction = Construct(type) as Faction; if (faction != null) { Faction.Factions.Add(faction); } } else if (type.IsSubclassOf(typeof(Town))) { Town town = Construct(type) as Town; if (town != null) { Town.Towns.Add(town); } } } } }
public static void FindMobile_OnCommand(CommandEventArgs e) { if (e.Length > 1) { LogHelper Logger = new LogHelper("findMobile.log", e.Mobile, false); // Extract property & value from command parameters string sProp = e.GetString(0); string sVal = ""; if (e.Length > 2) { sVal = e.GetString(1); // Concatenate the strings for (int argi = 2; argi < e.Length; argi++) { sVal += " " + e.GetString(argi); } } else { sVal = e.GetString(1); } Regex PattMatch = new Regex("= \"*" + sVal, RegexOptions.IgnoreCase); // Loop through assemblies and add type if has property Type[] types; Assembly[] asms = ScriptCompiler.Assemblies; ArrayList MatchTypes = new ArrayList(); for (int i = 0; i < asms.Length; ++i) { types = ScriptCompiler.GetTypeCache(asms[i]).Types; foreach (Type t in types) { if (typeof(Mobile).IsAssignableFrom(t)) { // Reflect type PropertyInfo[] allProps = t.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo prop in allProps) { if (prop.Name.ToLower() == sProp.ToLower()) { MatchTypes.Add(t); } } } } } // Loop items and check vs. types foreach (Mobile m in World.Mobiles.Values) { Type t = m.GetType(); bool match = false; foreach (Type MatchType in MatchTypes) { if (t == MatchType) { match = true; break; } } if (match == false) { continue; } // Reflect instance of type (matched) if (PattMatch.IsMatch(Properties.GetValue(e.Mobile, m, sProp))) { Logger.Log(LogType.Mobile, m); } } Logger.Finish(); } else { // Badly formatted e.Mobile.SendMessage("Format: FindMobile <property> <value>"); } }
public static Type[] GetTypeCache(this Assembly asm) { return(ScriptCompiler.GetTypeCache(asm).Types); }