JsonObjectCreationHandlingAttribute 类

定义

确定反序列化如何处理字段或属性的对象创建。

public ref class JsonObjectCreationHandlingAttribute sealed : System::Text::Json::Serialization::JsonAttribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Field | System.AttributeTargets.Interface | System.AttributeTargets.Property | System.AttributeTargets.Struct, AllowMultiple=false)]
public sealed class JsonObjectCreationHandlingAttribute : System.Text.Json.Serialization.JsonAttribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Field | System.AttributeTargets.Interface | System.AttributeTargets.Property | System.AttributeTargets.Struct, AllowMultiple=false)>]
type JsonObjectCreationHandlingAttribute = class
    inherit JsonAttribute
Public NotInheritable Class JsonObjectCreationHandlingAttribute
Inherits JsonAttribute
继承
JsonObjectCreationHandlingAttribute
属性

注解

当放置在字段或属性上时,此属性指示是替换还是填充成员。 使用默认解析程序时,此属性映射到 ObjectCreationHandling

当放置在具有 Populate的类型上时,此属性指示将填充支持填充的所有成员。 使用默认解析程序时,此属性映射到 PreferredPropertyObjectCreationHandling

属性仅对应于放置在类型上时属性的创建处理的首选值。 例如,当 JsonObjectCreationHandlingAttribute 将 with Populate 放置在类上并且无法填充属性时,将替换该属性。 例如,如果值类型没有 setter,或者 属性的类型为 IEnumerable<T>,则可能是 true

仅考虑属性类型。 例如,如果 属性的类型 IEnumerable<T> 为 ,并且其运行时值的类型为 List<T>,则不会填充该属性,因为 IEnumerable<T> 无法填充。

值类型需要一个 setter 来支持填充。 在这种情况下,反序列化使用属性值的副本,该副本将在完成后分配回资源库。

构造函数

JsonObjectCreationHandlingAttribute(JsonObjectCreationHandling)

初始化 JsonObjectCreationHandlingAttribute 的新实例。

属性

Handling

获取反序列化成员时要使用的配置。

TypeId

在派生类中实现时,获取此 Attribute 的唯一标识符。

(继承自 Attribute)

方法

Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。

(继承自 Attribute)
GetHashCode()

返回此实例的哈希代码。

(继承自 Attribute)
GetType()

获取当前实例的 Type

(继承自 Object)
IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否是派生类的默认值。

(继承自 Attribute)
Match(Object)

当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。

(继承自 Attribute)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于