| | | 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 | | using System.Collections.Generic; |
| | | 5 | | using System.ComponentModel; |
| | | 6 | | |
| | | 7 | | namespace System.Text.Json.Serialization.Metadata |
| | | 8 | | { |
| | | 9 | | /// <summary> |
| | | 10 | | /// Provides serialization metadata about a union type. |
| | | 11 | | /// </summary> |
| | | 12 | | /// <typeparam name="T">The union type to serialize or deserialize.</typeparam> |
| | | 13 | | /// <remarks>This API is for use by the output of the System.Text.Json source generator and should not be called dir |
| | | 14 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| | | 15 | | public sealed class JsonUnionInfoValues<T> |
| | | 16 | | { |
| | | 17 | | /// <summary> |
| | | 18 | | /// Gets or sets the list of union case type metadata for the current union type. |
| | | 19 | | /// </summary> |
| | | 20 | | /// <remarks>This API is for use by the output of the System.Text.Json source generator and should not be called |
| | 0 | 21 | | public IList<JsonUnionCaseInfo>? UnionCases { get; init; } |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// Gets or sets the delegate used to construct a union instance from a case type and case value. |
| | | 25 | | /// </summary> |
| | | 26 | | /// <remarks>This API is for use by the output of the System.Text.Json source generator and should not be called |
| | 0 | 27 | | public Func<Type, object?, T>? UnionConstructor { get; init; } |
| | | 28 | | |
| | | 29 | | /// <summary> |
| | | 30 | | /// Gets or sets the delegate used to deconstruct a union instance into its case type and case value. |
| | | 31 | | /// </summary> |
| | | 32 | | /// <remarks> |
| | | 33 | | /// This API is for use by the output of the System.Text.Json source generator and should not be called directly |
| | | 34 | | /// Refer to <see cref="JsonTypeInfo.UnionDeconstructor"/> for the full <c>(CaseType, CaseValue)</c> |
| | | 35 | | /// contract — including the role of a <see langword="null"/> <c>CaseType</c> as the |
| | | 36 | | /// discriminator for the canonical null-union state. |
| | | 37 | | /// </remarks> |
| | 0 | 38 | | public Func<T, (Type? CaseType, object? CaseValue)>? UnionDeconstructor { get; init; } |
| | | 39 | | |
| | | 40 | | /// <summary> |
| | | 41 | | /// Gets or sets the delegate used to classify JSON payloads during union deserialization. |
| | | 42 | | /// </summary> |
| | | 43 | | /// <remarks>This API is for use by the output of the System.Text.Json source generator and should not be called |
| | 0 | 44 | | public JsonTypeClassifier? TypeClassifier { get; init; } |
| | | 45 | | |
| | | 46 | | /// <summary> |
| | | 47 | | /// Gets or sets a factory used to lazily construct a <see cref="JsonTypeClassifier"/> |
| | | 48 | | /// from the union's metadata at <see cref="JsonTypeInfo"/> configuration time. |
| | | 49 | | /// </summary> |
| | | 50 | | /// <remarks> |
| | | 51 | | /// This API is for use by the output of the System.Text.Json source generator and should not be called directly |
| | | 52 | | /// Resolved from <see cref="JsonUnionAttribute.TypeClassifier"/> at compile time. |
| | | 53 | | /// When both this property and <see cref="TypeClassifier"/> are set, the explicit |
| | | 54 | | /// classifier delegate wins and the factory is ignored. |
| | | 55 | | /// </remarks> |
| | 0 | 56 | | public JsonTypeClassifierFactory? TypeClassifierFactory { get; init; } |
| | | 57 | | } |
| | | 58 | | } |
| | | 59 | | |