private static Type GetTypeByCommandVersion(string command, Version version) { if (!Lookups.ContainsKey(command) || Lookups[command] == null) { return(null); } Type tempDefaultType = null; Type formerType = null; foreach (var kv in Lookups[command]) { if (kv.Item1.IsAny()) { tempDefaultType = kv.Item2; continue;//假如脚本有2个按钮,优先匹配带版本的按钮,因此Continue; } if (kv.Item1.IsBelongsToMe(version)) { formerType = kv.Item2; break; } } if (formerType == null && tempDefaultType != null) { formerType = tempDefaultType; } return(formerType); }
public BlockLookupTable() { var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"LookupTable", "runtimeid_table.json"); var json = File.ReadAllText(path); var table = JsonConvert.DeserializeObject <List <LookUp> >(json); foreach (var t in table) { if (t.data.HasValue) { var key = CreateKey(t.id, t.data.Value); if (!Lookups.ContainsKey(key)) { Lookups.Add(key, t); } } } }