public static T LoadFromXml <T>(String fileName) { XtraXmlSerializer serializer = new XtraXmlSerializer(typeof(T)); using (TextReader reader = new StreamReader(fileName)) { return((T)serializer.Deserialize(reader)); } }
public static T DeserializeFromXml <T>(String xmlText) { XtraXmlSerializer serializer = new XtraXmlSerializer(typeof(T)); using (Stream storage = new MemoryStream()) { byte[] encoded = Encoding.UTF8.GetBytes(xmlText); storage.Write(encoded, 0, encoded.Length); storage.Seek(0, SeekOrigin.Begin); using (TextReader reader = new StreamReader(storage)) { return((T)serializer.Deserialize(reader)); } } }