gpt4 book ai didi

.net - 每个序列化程序都支持 OnDeserializedAttribute 吗?

转载 作者:行者123 更新时间:2023-12-04 05:23:00 26 4
gpt4 key购买 nike

我只是偶然发现 OnDeserializedAttribute on MSDN .描述指出

When applied to a method, specifies that the method is called immediately after deserialization of an object in an object graph. The order of deserialization relative to other objects in the graph is non-deterministic.



问题
  • 是否为任何序列化程序调用了具有此属性的方法?
  • 如果是这样,.NET 如何确保为任意序列化程序调用该方法?
  • 如果不是,它是否支持所有“常见”序列化程序(BinaryFormatter、XmlSerializer、JSON Serializer、DataContractSerializer)?
  • 最佳答案

  • It does not work on the XmlSerializer .
  • 它不做任何强制执行。这是序列化程序的“选择加入”功能。
  • 它适用于 BinaryFormatter 和 DataContractSerializer。
  • 关于.net - 每个序列化程序都支持 OnDeserializedAttribute 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13501525/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com