public static T Read <T>(string filename) where T : Serializable, new() { var filecontent = ""; using (var fs = new FileStream(filename, FileMode.Open)) { using (var sr = new StreamReader(fs)) { filecontent = sr.ReadToEnd(); } } if (!string.IsNullOrEmpty(filecontent)) { try { return(SerializeableMaker.FromString <T>(filecontent)); } catch (Exception ex) { throw ex; } } throw new SerializationException("Couldn't read file!"); }
public void Deserialize(string serializedString) { var lines = serializedString.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { try { Add(SerializeableMaker.FromString <T>(line)); } catch (Exception ex) { throw ex as DeserializationException; } } }