XmlSerializer.Serialize为什么偶尔会序列化空对象?
public static void Serialize(Setting setting)
{
XmlSerializer xml = new XmlSerializer(typeof(Setting));
var file = ApplicationData.Current.LocalFolder.CreateFileAsync("__setting.xml", CreationCollisionOption.ReplaceExisting).AsTask().Result;
using (Stream stream = file.OpenStreamForWriteAsync().Result)
{
xml.Serialize(stream, setting);
stream.Flush();
}
}