static PersonDataStore() { var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin", "data.csv"); using (var reader = new DelimitedDataReader(filePath, true, 0, 0, ',')) { while (reader.Read()) { people.Add(GetPerson(reader)); } } }
private static Person GetPerson(DelimitedDataReader reader) { Gender gender; Enum.TryParse(reader["gender"], out gender); return(new Person { Id = Convert.ToInt32(reader["id"]), FirstName = reader["first_name"], LastName = reader["last_name"], EmailAddress = reader["email"], Gender = gender, Country = reader["country"], Buzzwords = reader["buzzword"], Pets = petStore.GetRandom() }); }