Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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;
        }
Esempio n. 3
0
        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);
                    }
                }
            }
        }