0
我有寫我的自定義對象到XML磁盤上的一個簡單的序列化類:常規XML序列化反序列化一般
public class ReaderWriter
{
public static void StoreObjectInformationInFile<T>(T objectToBeWritten, string passedDestinationFileName)
{
XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(objectToBeWritten.GetType());
TextWriter writer = new StreamWriter(passedDestinationFileName);
serializer.Serialize(writer, objectToBeWritten);
writer.Close();
}
}
有沒有辦法爲通用反序列化功能添加到這個類,做同樣的事情,但相反?是這樣的:
public static <T> GetObjectInformationFromFile<T>(string passedDestinationFileName)
{
...
}