Using Generics to Generalize the Save and Load Xml

public ObjectType ReadXml<ObjectType>(string fileName)
{
    using (var sw = new StreamReader(ENV.PathDecoder.DecodePath(fileName)))
    {
        return (ObjectType)new XmlSerializer(typeof(ObjectType)).Deserialize(sw);
    }
}

public void SaveXml<ObjectType>(ObjectType o, string fileName)
{
    using (var sw = new StreamWriter(ENV.PathDecoder.DecodePath(fileName)))
    {
        new XmlSerializer(typeof(ObjectType)).Serialize(sw, o);
    }
} 

Help us improve, Edit this page on GitHub
or email us at info@fireflymigration.com