| | | 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.Metadata |
| | | 5 | | { |
| | | 6 | | /// <summary> |
| | | 7 | | /// Represents metadata for a single case type within a union type. |
| | | 8 | | /// </summary> |
| | | 9 | | public sealed class JsonUnionCaseInfo |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// Initializes a new instance of <see cref="JsonUnionCaseInfo"/> with the specified case type. |
| | | 13 | | /// </summary> |
| | | 14 | | /// <param name="caseType">The type representing this union case.</param> |
| | | 15 | | /// <exception cref="ArgumentNullException"><paramref name="caseType"/> is <see langword="null"/>.</exception> |
| | 0 | 16 | | public JsonUnionCaseInfo(Type caseType) |
| | 0 | 17 | | { |
| | 0 | 18 | | ArgumentNullException.ThrowIfNull(caseType); |
| | 0 | 19 | | CaseType = caseType; |
| | 0 | 20 | | } |
| | | 21 | | |
| | | 22 | | /// <summary> |
| | | 23 | | /// Gets the type representing this union case. |
| | | 24 | | /// </summary> |
| | 0 | 25 | | public Type CaseType { get; } |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// Gets a value indicating whether this case can hold a <see langword="null"/> value. |
| | | 29 | | /// </summary> |
| | | 30 | | /// <remarks> |
| | | 31 | | /// Set to <see langword="true"/> when the union constructor parameter for this case |
| | | 32 | | /// was declared as a nullable reference type or as <see cref="Nullable{T}"/>. |
| | | 33 | | /// When a JSON <see langword="null"/> is encountered during deserialization, |
| | | 34 | | /// the first union case whose <see cref="IsNullable"/> is <see langword="true"/> |
| | | 35 | | /// is selected and its case constructor is invoked with <see langword="null"/>. |
| | | 36 | | /// </remarks> |
| | 0 | 37 | | public bool IsNullable { get; init; } |
| | | 38 | | } |
| | | 39 | | } |
| | | 40 | | |