Edytuj

Udostępnij za pośrednictwem


JsonObjectCreationHandlingAttribute Class

Definition

Determines how deserialization handles object creation for fields or properties.

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
Inheritance
JsonObjectCreationHandlingAttribute
Attributes

Remarks

When placed on a field or property, this attribute indicates if the member will be replaced or populated. When default resolvers are used, this attribute maps to ObjectCreationHandling.

When placed on a type with Populate, this attribute indicates that all members that support population will be populated. When default resolvers are used, this attribute maps to PreferredPropertyObjectCreationHandling.

The attribute corresponds only to the preferred values of creation handling for properties when placed on a type. For example, when JsonObjectCreationHandlingAttribute with Populate is placed on a class and a property is not capable of being populated, it will be replaced. That might be true if, for example, the value type doesn't have a setter or the property is of type IEnumerable<T>.

Only the property type is taken into consideration. For example, if the property is of type IEnumerable<T> has and has a run-time value of type List<T>, it won't be populated because IEnumerable<T> is not capable of populating.

Value types require a setter to support population. In such cases, deserialization uses a copy of the property value, which will get assigned back to the setter once finished.

Constructors

JsonObjectCreationHandlingAttribute(JsonObjectCreationHandling)

Initializes a new instance of JsonObjectCreationHandlingAttribute.

Properties

Handling

Gets the configuration to use when deserializing members.

TypeId

When implemented in a derived class, gets a unique identifier for this Attribute.

(Inherited from Attribute)

Methods

Equals(Object)

Returns a value that indicates whether this instance is equal to a specified object.

(Inherited from Attribute)
GetHashCode()

Returns the hash code for this instance.

(Inherited from Attribute)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
IsDefaultAttribute()

When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(Inherited from Attribute)
Match(Object)

When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(Inherited from Attribute)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to