private static CarName GetDefault(uint carID) { CarName defaultName = defaultStrings.SingleOrDefault(carName => carName.CarID == carID) ?? throw new Exception($"Car name for {carID} not found."); strings.Add(defaultName); return(defaultName); }
public override void Import(string filename) { base.Import(filename); CarName carName = CarNameStringTable.Get(data.CarId); CarData carData = data; carData.NameFirstPart = UnicodeStringTable.Add(carName.NameFirstPart); carData.NameSecondPart = UnicodeStringTable.Add(carName.NameSecondPart); carData.Year = carName.Year; data = carData; }
private static void ImportCSV(string filename, List <CarName> strings) { using (TextReader input = new StreamReader(filename, Encoding.UTF8)) { using (CsvReader csv = new CsvReader(input)) { csv.Configuration.RegisterClassMap <CarNameCSVMap>(); csv.Read(); csv.ReadHeader(); while (csv.Read()) { CarName carName = csv.GetRecord <CarName>(); strings.RemoveAll(existingCarName => existingCarName.CarID == carName.CarID); strings.Add(carName); } } } }