我正在使用下面的代码将拓扑类序列化为 xml:
public static bool WriteTopologyFile(string path)
{
try
{
XmlSerializer serializer = new XmlSerializer(typeof(Topology));
using (StreamWriter reader = new StreamWriter(path))
{
serializer.Serialize(reader, Runtime.Topology);
}
return true;
}
catch (Exception ex)
{
Log.WriteEventLog(ex, EventLogEntryType.Error);
}
return false;
}
在 Topology 类中,有一些 DateTime 字段,我想将这些 DateTime 字段序列化
System.Xml.XmlDateTimeSerializationMode.RoundtripKind
模式。我怎样才能做到这一点?