示例#1
0
 private void Add(TrainRule rule)
 {
     if (rules.ContainsKey(rule.Name))
     {
         rules[rule.Name] = rule;
     }
     else
     {
         rules.Add(rule.Name, rule);
     }
 }
示例#2
0
        private TrainRule GetRule(string name)
        {
            TrainRule rule;

            if (rules.ContainsKey(name))
            {
                rule = rules[name];
            }
            else
            {
                rule = new TrainRule(name);
                Add(rule);
            }

            return(rule);
        }