private void Add(TrainRule rule) { if (rules.ContainsKey(rule.Name)) { rules[rule.Name] = rule; } else { rules.Add(rule.Name, rule); } }
private TrainRule GetRule(string name) { TrainRule rule; if (rules.ContainsKey(name)) { rule = rules[name]; } else { rule = new TrainRule(name); Add(rule); } return(rule); }