public Person Parse(string data, DataMeta meta) { var record = data.Split(meta.Delimiter); var person = new Person(); try { person.LastName = record[meta.Fields["lastname"]].Trim(); person.FirstName = record[meta.Fields["firstname"]].Trim(); person.Gender = ValidateGender(record[meta.Fields["gender"]]); person.DateOfBirth = Convert.ToDateTime(record[meta.Fields["dateofbirth"]]); person.FavoriteColor = record[meta.Fields["favoritecolor"]].Trim(); } catch (Exception e) { //we should probably throw a custom exception here. throw new PersonParserException("Invalid Person raw data", e); //we should handle a bad record here } return(person); }
public DataFile() { Meta = new DataMeta(); Items = new List <T>(); Errors = new List <DataError>(); }