public static ConcurrentDictionary<int, IHaltestelle> ReadFile(String filePath) { FileHelperEngine<HaltestelleRecord> engine = new FileHelperEngine<HaltestelleRecord>(); ConcurrentDictionary<int, IHaltestelle> haltestellen = new ConcurrentDictionary<int, IHaltestelle>(); try { engine.ErrorManager.ErrorMode = ErrorMode.SaveAndContinue; engine.Encoding = Encoding.UTF8; HaltestelleRecord[] res = engine.ReadFile(filePath); foreach (HaltestelleRecord haltestelle in res) { //Übernehmen der eingelesenen Daten in das Programm-Model: IHaltestelle transport = new Haltestelle(); Point HsLoc = new Point(haltestelle.XKoord, haltestelle.YKoord); transport.Diva = haltestelle.Diva; transport.Id = haltestelle.Id; transport.Location = HsLoc; transport.Name = haltestelle.Name; //Schreiben des Models in Collection für den Rückgabewert: haltestellen.AddOrUpdate(transport.Id, transport, (key, oldValue) => transport); } } catch (Exception ex) { //Dokument konnte nicht geparst werden (Nicht vorhanden/geöffnet) throw new VtmParsingException("Beim Versuch die Haltestellen zu parsen ist ein Fehler aufgetreten!", filePath, ex); } return (haltestellen); }
public override bool Equals(Object obj) { Haltestelle halt = obj as Haltestelle; if (halt == null) { return(false); } return((halt).Id.Equals(this.Id)); }
public void TestInitialize() { point = new Point(123.4, 432.1); halt = new Haltestelle(1, 1234, "Test-Haltestelle", point); haltLeer = new Haltestelle(); }