/// <inheritdoc /> /// <summary> /// Deserializes from file. /// </summary> /// <param name="type">The type.</param> /// <param name="file">The file.</param> /// <returns>System.Object.</returns> public object DeserializeFromFile(Type type, string fullFilePath) { var file = new FileObject(fullFilePath); if (file.Exist != true) { throw new FileNotFoundException(fullFilePath); } using (TextReader fileReader = file.GetStreamReader()) { using (var csv = new CsvReader(fileReader, Configuration)) { if (type.IsTypeIEnumerable()) { return(csv.GetRecords(type)); } else { // PreCheck(csv); csv.Read(); return(csv.GetRecord(type)); } } } }
/// <inheritdoc /> public dynamic DeserializeFromFile(string fullFilePath) { var file = new FileObject(fullFilePath); if (file.Exist != true) { throw new FileNotFoundException(fullFilePath); } using (TextReader fileReader = file.GetStreamReader()) { using (var csv = new CsvReader(fileReader, Configuration)) { return(csv.GetRecord <dynamic>()); } } }
public IEnumerable <T> DeserializeListFromFile <T>(string fullFilePath) where T : class { var file = new FileObject(fullFilePath); if (file.Exist != true) { throw new FileNotFoundException(fullFilePath); } using (TextReader fileReader = file.GetStreamReader()) { using (var csv = new CsvReader(fileReader, Configuration)) { return(csv.GetRecords <T>().ToList()); } } }