public void SerializeObject<T>(T serializableObject, string fileName) { if (serializableObject == null) return; var serializer = new XmlSerializer(serializableObject.GetType()); using (var stream = File.Open(fileName, FileMode.Create)) { serializer.Serialize(stream, serializableObject); } } public T DeserializeObject<T>(string fileName) { XmlAttributeOverrides overrides = new XmlAttributeOverrides(); XmlAttributes attributes = new XmlAttributes(); attributes.XmlIgnore = false; if (string.IsNullOrEmpty(fileName)) return default(T); var serializer = new XmlSerializer(typeof(T),overrides); using (var stream = File.Open(fileName, FileMode.Open)) { return (T)serializer.Deserialize(stream); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)