XmlSerialization with a singleton

我们两清 提交于 2019-12-06 08:46:43

I haven't found a way to do this natively with XmlSerializer. I did find an old thread between Jon Skeet and Marc Gravell that basically says that you can't do this the same way that you could with ISerializable and IObjectReference.

The way I had to make this work was along the following lines:

  • Add a Guid field to the Binder object (i.e. the common object shared by multiple objects)
  • During deserialization, use a static Dictionary and either use an already registered Binder object with the same Guid or add a new Binder object to the static dictionary for others to link against.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!