ReferenceResolver 类
定义
此类定义 JsonSerializer 如何处理对序列化和反序列化的引用。This class defines how the JsonSerializer deals with references on serialization and deserialization. 定义在序列化和反序列化过程中保留引用的核心行为。Defines the core behavior of preserving references on serialization and deserialization.
public ref class ReferenceResolver abstract
public abstract class ReferenceResolver
type ReferenceResolver = class
Public MustInherit Class ReferenceResolver
- 继承
-
ReferenceResolver
构造函数
| ReferenceResolver() |
初始化 ReferenceResolver 类的新实例。Initializes a new instance of the ReferenceResolver class. |
方法
| AddReference(String, Object) |
使用指定的 ID 和值向引用包中添加一个项。Adds an entry to the bag of references using the specified id and value. 从 JSON 对象中读取 $id 元数据属性时,将调用此方法。This method gets called when an $id metadata property from a JSON object is read. |
| Equals(Object) |
确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object. (继承自 Object) |
| GetHashCode() |
作为默认哈希函数。Serves as the default hash function. (继承自 Object) |
| GetReference(Object, Boolean) |
获取指定值的引用标识符(如果存在);否则,将分配一个新 ID。Gets the reference identifier of the specified value if exists; otherwise a new id is assigned. 在编写 CLR 对象之前调用此方法,便于我们决定是写入 $id 并枚举其属性的其余部分,还是写入 $ref 并单步执行下一个对象。This method gets called before a CLR object is written so we can decide whether to write $id and enumerate the rest of its properties or $ref and step into the next object. |
| GetType() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
| MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 Object) |
| ResolveReference(String) |
返回与指定的引用 ID 相关的 CLR 引用类型对象。当读取 $ref 元数据属性时,将调用此方法。Returns the CLR reference type object related to the specified reference id. This method gets called when $ref metadata property is read. |
| ToString() |
返回表示当前对象的字符串。Returns a string that represents the current object. (继承自 Object) |