public bool TryRead <T>(string filepath, out List <T> list, out string message) where T : class, new() { bool b = false; list = null; message = string.Empty; try { if (File.Exists(filepath)) { //string filecontents = File.ReadAllText(filepath); //if (!string.IsNullOrWhiteSpace(filecontents)) //{ // list = JsonConvert.DeserializeObject<List<T>>(filecontents); // b = true; //} list = GenericObjectManager.ReadGenericList <T>(filepath); b = true; } } catch (Exception ex) { message = ex.InnerException != null ? ex.InnerException.Message : ex.Message; } return(b); }
public bool TryRead <T>(out List <T> list, out string message, string filepath = "") where T : class, new() { bool b = false; message = string.Empty; list = new List <T>(); filepath = !String.IsNullOrWhiteSpace(filepath) ? filepath : Filepath <T>(); try { if (File.Exists(filepath)) { list = GenericObjectManager.ReadGenericList <T>(filepath); string filecontents = File.ReadAllText(filepath); if (!string.IsNullOrWhiteSpace(filecontents)) { //list = JsonConvert.DeserializeObject<List<T>>(filecontents); } //b = list.Count > 0; } } catch (Exception ex) { message = ex.InnerException != null ? ex.InnerException.Message : ex.Message; } return(b); }