public static string SerializeDTO <T>([NotNull] DtoDbBase <T> dto) where T : DtoDbBase <T> { XmlSerializer xmlSer = new XmlSerializer(dto.GetType()); //using (TextWriter tw = new StreamWriter(xmlFilePath)) // xmlSer.Serialize(tw, dto); StringWriter sWriter = new StringWriter(); xmlSer.Serialize(sWriter, dto); return(sWriter.ToString()); }
public static DtoDbBase <T> DeserializeXml <T>(string xml, DtoDbBase <T> dto) where T : DtoDbBase <T> { XmlSerializer xmlSer = new XmlSerializer(dto.GetType()); //using (TextReader tr = new StreamReader(xmlFilePath)) //{ // DtoDbBase retDTO = (DtoDbBase) xmlSer.Deserialize(tr); // return retDTO; //} StringReader sReader = new StringReader(xml); DtoDbBase <T> retDTO = (DtoDbBase <T>)xmlSer.Deserialize(sReader); return(retDTO); }
public bool Equals(DtoDbBase <T> other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } if (this.GetType() != other.GetType()) { return(false); } return(InteriorEquals((T)other)); }