This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static T Deserialize<T>(this T obj, string xmlFilePath) | |
{ | |
XmlSerializer serializer = new XmlSerializer(typeof(T)); | |
StreamReader reader = new StreamReader(xmlFilePath); | |
obj = (T)serializer.Deserialize(reader); | |
reader.Close(); | |
return obj; | |
} | |
public static void Serialize<T>(this T obj, string filePath) | |
{ | |
XmlSerializer writer = new XmlSerializer(typeof(T)); | |
StreamWriter file = new StreamWriter(filePath); | |
writer.Serialize(file, obj); | |
file.Close(); | |
} |
No comments:
Post a Comment