| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | namespace System.Text.Json.Serialization |
| | | 5 | | { |
| | | 6 | | /// <summary> |
| | | 7 | | /// When placed on a type, indicates that the type should be serialized polymorphically. |
| | | 8 | | /// </summary> |
| | | 9 | | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false, Inherited = false)] |
| | | 10 | | public sealed class JsonPolymorphicAttribute : JsonAttribute |
| | | 11 | | { |
| | | 12 | | /// <summary> |
| | | 13 | | /// Gets or sets a custom type discriminator property name for the polymorphic type. |
| | | 14 | | /// Uses the default '$type' property name if left unset. |
| | | 15 | | /// </summary> |
| | 0 | 16 | | public string? TypeDiscriminatorPropertyName { get; set; } |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Gets or sets the behavior when serializing an undeclared derived runtime type. |
| | | 20 | | /// </summary> |
| | 0 | 21 | | public JsonUnknownDerivedTypeHandling UnknownDerivedTypeHandling { get; set; } |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// When set to <see langword="true"/>, instructs the deserializer to ignore any |
| | | 25 | | /// unrecognized type discriminator id's and reverts to the contract of the base type. |
| | | 26 | | /// Otherwise, it will fail the deserialization. |
| | | 27 | | /// </summary> |
| | 0 | 28 | | public bool IgnoreUnrecognizedTypeDiscriminators { get; set; } |
| | | 29 | | } |
| | | 30 | | } |