private void AddLineRelation(StationRelation relation) { if (relation.From.Line == relation.To.Line) { throw new ArgumentException(); } ISet <Station> r1; if (!LineRelationStations.TryGetValue(relation.From.Line, out r1)) { r1 = new HashSet <Station>(); LineRelationStations.Add(relation.From.Line, r1); } r1.Add(relation.From); ISet <Station> r2; if (!LineRelationStations.TryGetValue(relation.To.Line, out r2)) { r2 = new HashSet <Station>(); LineRelationStations.Add(relation.To.Line, r2); } r2.Add(relation.To); }
public IEnumerable <Station> GetLineRelationStations(Line line) { if (LineRelationStations.TryGetValue(line, out var result)) { return(result); } throw new KeyNotFoundException(); }