forked from OrchardCMS/OrchardCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use ContentSerializerJsonOptions to configure content-serializer (Orc…
- Loading branch information
1 parent
c00116b
commit 1a0cd2f
Showing
24 changed files
with
106 additions
and
80 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
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
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
31 changes: 31 additions & 0 deletions
31
...hardCore/OrchardCore.Abstractions/Extensions/ContentSerializerJsonOptionsConfiguration.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,31 @@ | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
using Microsoft.Extensions.Options; | ||
using OrchardCore.Json; | ||
using OrchardCore.Json.Serialization; | ||
|
||
namespace OrchardCore.Extensions; | ||
|
||
public class ContentSerializerJsonOptionsConfiguration : IConfigureOptions<ContentSerializerJsonOptions> | ||
{ | ||
private readonly JsonDerivedTypesOptions _derivedTypesOptions; | ||
|
||
public ContentSerializerJsonOptionsConfiguration(IOptions<JsonDerivedTypesOptions> derivedTypesOptions) | ||
{ | ||
_derivedTypesOptions = derivedTypesOptions.Value; | ||
} | ||
|
||
public void Configure(ContentSerializerJsonOptions options) | ||
{ | ||
options.SerializerOptions.DefaultIgnoreCondition = JOptions.Base.DefaultIgnoreCondition; | ||
options.SerializerOptions.ReferenceHandler = JOptions.Base.ReferenceHandler; | ||
options.SerializerOptions.ReadCommentHandling = JOptions.Base.ReadCommentHandling; | ||
options.SerializerOptions.PropertyNameCaseInsensitive = JOptions.Base.PropertyNameCaseInsensitive; | ||
options.SerializerOptions.AllowTrailingCommas = JOptions.Base.AllowTrailingCommas; | ||
options.SerializerOptions.WriteIndented = JOptions.Base.WriteIndented; | ||
|
||
options.SerializerOptions.TypeInfoResolverChain.Add(new PolymorphicJsonTypeInfoResolver(_derivedTypesOptions)); | ||
options.SerializerOptions.Converters.Add(DynamicJsonConverter.Instance); | ||
options.SerializerOptions.Converters.Add(PathStringJsonConverter.Instance); | ||
} | ||
} |
32 changes: 0 additions & 32 deletions
32
src/OrchardCore/OrchardCore.Abstractions/Extensions/JsonSerializerOptionsConfiguration.cs
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
src/OrchardCore/OrchardCore.Abstractions/Json/ContentSerializerJsonOptions.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,8 @@ | ||
using System.Text.Json; | ||
|
||
namespace OrchardCore.Json; | ||
|
||
public class ContentSerializerJsonOptions | ||
{ | ||
public JsonSerializerOptions SerializerOptions { get; } = new JsonSerializerOptions(); | ||
} |
Oops, something went wrong.