-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement a polymorphic serialization prototype
- Loading branch information
1 parent
9414d57
commit 8a0d317
Showing
49 changed files
with
2,856 additions
and
574 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
.../System.Text.Json/src/System/Text/Json/Serialization/Attributes/JsonKnownTypeAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace System.Text.Json.Serialization | ||
{ | ||
/// <summary> | ||
/// When placed on a type, indicates that the specified subtype should | ||
/// be serialized polymorphically using type discriminator identifiers. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)] | ||
public class JsonKnownTypeAttribute : JsonAttribute | ||
{ | ||
/// <summary> | ||
/// Initializes a new attribute with specified parameters. | ||
/// </summary> | ||
/// <param name="subtype">The known subtype that should be serialized polymorphically.</param> | ||
/// <param name="identifier">The string identifier to be used for the serialization of the subtype.</param> | ||
public JsonKnownTypeAttribute(Type subtype, string identifier) | ||
{ | ||
Subtype = subtype; | ||
Identifier = identifier; | ||
} | ||
|
||
/// <summary> | ||
/// The known subtype that should be serialized polymorphically. | ||
/// </summary> | ||
public Type Subtype { get; } | ||
|
||
/// <summary> | ||
/// The string identifier to be used for the serialization of the subtype. | ||
/// </summary> | ||
public string Identifier { get; } | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...m.Text.Json/src/System/Text/Json/Serialization/Attributes/JsonPolymorphicTypeAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace System.Text.Json.Serialization | ||
{ | ||
/// <summary> | ||
/// When placed on a type, indicates that values should | ||
/// be serialized using the schema of their runtime types. | ||
/// </summary> | ||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false, Inherited = false)] | ||
public sealed class JsonPolymorphicTypeAttribute : JsonAttribute | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.