From 1c9d4a4da5a92825a642de20306bc3b4d450158c Mon Sep 17 00:00:00 2001 From: jtkech Date: Tue, 24 Oct 2023 10:06:56 +0200 Subject: [PATCH 01/86] Remove Newtonsoft --- .../Recipes/AdminMenuStep.cs | 11 +- .../Settings/BooleanFieldSettingsDriver.cs | 3 +- .../Settings/DateFieldSettingsDriver.cs | 3 +- .../Settings/DateTimeFieldSettingsDriver.cs | 3 +- .../Settings/LinkFieldSettingsDriver.cs | 3 +- ...tionSetContentPickerFieldSettingsDriver.cs | 5 +- .../Settings/NumericFieldSettingsDriver.cs | 3 +- .../Settings/TextFieldSettingsDriver.cs | 3 +- .../Settings/TimeFieldSettingsDriver.cs | 3 +- .../Settings/YoutubeFieldSettingsDriver.cs | 13 +- .../RecipeSteps/ContentDefinitionStep.cs | 1 + .../DeleteContentDefinitionStep.cs | 1 + .../ReplaceContentDefinitionStep.cs | 1 + .../Recipes/LuceneRecipeEventHandler.cs | 14 +- .../ViewModels/EditTypeViewModel.cs | 6 +- .../Controllers/ApiController.cs | 2 +- .../Recipes/ContentStep.cs | 4 +- .../Scripting/ContentMethodsProvider.cs | 3 +- .../Workflows/Activities/UpdateContentTask.cs | 12 +- .../OrchardCore.Cors/Services/CorsService.cs | 2 +- .../Drivers/CustomSettingsDisplayDriver.cs | 2 +- .../Recipes/CustomSettingsStep.cs | 17 +- .../Services/CustomSettingsService.cs | 6 +- .../Recipes/DeploymentPlansRecipeStep.cs | 4 +- .../Recipes/FacebookLoginSettingsStep.cs | 1 + .../Login/Services/FacebookLoginService.cs | 2 +- .../Recipes/FacebookSettingsStep.cs | 1 + .../Services/FacebookService.cs | 2 +- .../Recipes/Executors/FeatureStep.cs | 1 + .../GithubAuthenticationSettingsStep.cs | 1 + .../OrchardCore.Layers/Recipes/LayerStep.cs | 15 +- .../Recipes/MediaProfileStep.cs | 1 + .../OrchardCore.Media/Recipes/MediaStep.cs | 1 + .../Recipes/AzureADSettingsStep.cs | 1 + .../Recipes/MicrosoftAccountSettingsStep.cs | 1 + .../Recipes/OpenIdApplicationStep.cs | 1 + .../Recipes/OpenIdClientSettingsStep.cs | 1 + .../Recipes/OpenIdScopeStep.cs | 1 + .../Recipes/OpenIdServerSettingsStep.cs | 1 + .../Recipes/OpenIdValidationSettingsStep.cs | 1 + .../Services/OpenIdClientService.cs | 2 +- .../Services/OpenIdServerService.cs | 4 +- .../Services/OpenIdValidationService.cs | 4 +- .../Recipes/PlacementStep.cs | 8 +- .../OrchardCore.Queries/Recipes/QueryStep.cs | 6 +- .../RecipeSteps/CommandStep.cs | 1 + .../RecipeSteps/RecipesStep.cs | 1 + .../OrchardCore.Roles/Recipes/RolesStep.cs | 1 + ...tPickerFieldElasticEditorSettingsDriver.cs | 17 +- .../OrchardCore.Search.Lucene/Migrations.cs | 43 ++--- .../Recipes/LuceneIndexRebuildStep.cs | 1 + .../Recipes/LuceneIndexResetStep.cs | 1 + .../Recipes/LuceneIndexStep.cs | 8 +- ...ntPickerFieldLuceneEditorSettingsDriver.cs | 17 +- .../Controllers/AdminController.cs | 4 +- .../Recipes/SettingsStep.cs | 8 +- .../Recipes/ShortcodeTemplateStep.cs | 8 +- .../Recipes/SitemapsStep.cs | 17 +- .../Drivers/GeoPointFieldSettingsDriver.cs | 3 +- .../Views/GeoPointField-Leaflet.Edit.cshtml | 5 +- .../Views/GeoPointField.Edit.cshtml | 7 +- .../Settings/TaxonomyFieldSettingsDriver.cs | 3 +- .../TaxonomyFieldTagsEditorSettingsDriver.cs | 5 +- .../Recipes/AdminTemplateStep.cs | 8 +- .../Recipes/TemplateStep.cs | 8 +- .../Recipes/FeatureProfilesStep.cs | 8 +- .../OrchardCore.Themes/Recipes/ThemesStep.cs | 1 + .../Recipes/TwitterSettingsStep.cs | 1 + .../CustomUserSettingsDisplayDriver.cs | 6 +- .../Recipes/CustomUserSettingsStep.cs | 38 ++--- .../OrchardCore.Users/Recipes/UsersStep.cs | 1 + .../Services/CustomUserSettingsService.cs | 12 +- .../Recipes/WorkflowTypeStep.cs | 6 +- .../Services/WorkflowManager.cs | 6 +- .../Drivers/UserTaskEventContentDriver.cs | 1 + .../Json/JsonObjectExtensions.cs | 147 +++++++++++++++++ .../Json/JsonObjectHelper.cs | 71 ++++++++ .../Internal/JsonConfigurationParser.cs | 2 +- .../ContentElement.cs | 10 +- .../ContentExtensions.cs | 51 +++--- .../ContentItemConverter.cs | 105 ++++++------ .../ContentItemExtensions.cs | 11 +- .../IContentDefinitionManager.cs | 1 + .../Builders/ContentPartDefinitionBuilder.cs | 24 +-- .../ContentPartFieldDefinitionBuilder.cs | 22 +-- .../Builders/ContentTypeDefinitionBuilder.cs | 26 +-- .../ContentTypePartDefinitionBuilder.cs | 20 +-- .../Metadata/Models/ContentDefinition.cs | 26 +-- .../Metadata/Models/ContentPartDefinition.cs | 8 +- .../Models/ContentPartFieldDefinition.cs | 4 +- .../Metadata/Models/ContentTypeDefinition.cs | 8 +- .../Models/ContentTypePartDefinition.cs | 4 +- .../Metadata/Models/MetaDataExtensions.cs | 31 ---- .../Records/ContentPartDefinitionRecord.cs | 6 +- .../ContentPartFieldDefinitionRecord.cs | 4 +- .../Records/ContentTypeDefinitionRecord.cs | 4 +- .../ContentTypePartDefinitionRecord.cs | 4 +- .../ContentDefinitionManager.cs | 4 +- .../DefaultContentManager.cs | 24 +-- .../Records/Migrations.cs | 1 + .../DefaultJsonContentSerializer.cs | 40 +++++ .../OrchardCoreBuilderExtensions.cs | 4 +- .../Entities/SectionDisplayDriver.cs | 10 +- .../Documents/DocumentEntity.cs | 17 +- .../Documents/IDocumentSerialiser.cs | 1 - .../Entities/Entity.cs | 11 +- .../Entities/EntityExtensions.cs | 16 +- .../Entities/IEntity.cs | 11 +- .../Documents/DefaultDocumentSerializer.cs | 14 +- .../Documents/DocumentEntityManager.cs | 8 +- .../Models/RecipeExecutionContext.cs | 4 +- .../Services/RecipeExecutor.cs | 153 ++++++++++-------- .../VariablesMethodProvider.cs | 6 +- .../Models/ElasticIndexSettings.cs | 2 +- .../Recipes/ElasticIndexRebuildStep.cs | 1 + .../Recipes/ElasticIndexResetStep.cs | 1 + .../Recipes/ElasticIndexStep.cs | 5 +- .../Services/ElasticIndexingService.cs | 16 +- .../Activities/Activity.cs | 5 +- .../Activities/IActivity.cs | 4 +- .../Models/Workflow.cs | 4 +- .../Models/WorkflowState.cs | 4 +- .../Services/IActivityLibrary.cs | 4 +- .../Services/IWorkflowManager.cs | 4 +- 124 files changed, 831 insertions(+), 559 deletions(-) create mode 100644 src/OrchardCore/OrchardCore.Abstractions/Json/JsonObjectExtensions.cs create mode 100644 src/OrchardCore/OrchardCore.Abstractions/Json/JsonObjectHelper.cs delete mode 100644 src/OrchardCore/OrchardCore.ContentManagement.Abstractions/Metadata/Models/MetaDataExtensions.cs create mode 100644 src/OrchardCore/OrchardCore.Data.YesSql/DefaultJsonContentSerializer.cs diff --git a/src/OrchardCore.Modules/OrchardCore.AdminMenu/Recipes/AdminMenuStep.cs b/src/OrchardCore.Modules/OrchardCore.AdminMenu/Recipes/AdminMenuStep.cs index efc4c7c01f9..26a764f6ba5 100644 --- a/src/OrchardCore.Modules/OrchardCore.AdminMenu/Recipes/AdminMenuStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.AdminMenu/Recipes/AdminMenuStep.cs @@ -1,8 +1,7 @@ using System; using System.Linq; +using System.Text.Json.Nodes; using System.Threading.Tasks; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using OrchardCore.AdminMenu.Services; using OrchardCore.Recipes.Models; using OrchardCore.Recipes.Services; @@ -30,11 +29,11 @@ public async Task ExecuteAsync(RecipeExecutionContext context) var model = context.Step.ToObject(); - var serializer = new JsonSerializer() { TypeNameHandling = TypeNameHandling.Auto }; + // var serializer = new JsonSerializer() { TypeNameHandling = TypeNameHandling.Auto }; - foreach (var token in model.Data.Cast()) + foreach (var token in model.Data.Cast()) { - var adminMenu = token.ToObject(serializer); + var adminMenu = token.ToObject(/*serializer*/); // When the id is not supplied generate an id, otherwise replace the menu if it exists, or create a new menu. if (string.IsNullOrEmpty(adminMenu.Id)) @@ -51,6 +50,6 @@ public async Task ExecuteAsync(RecipeExecutionContext context) public class AdminMenuStepModel { - public JArray Data { get; set; } + public JsonArray Data { get; set; } } } diff --git a/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/BooleanFieldSettingsDriver.cs b/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/BooleanFieldSettingsDriver.cs index a575124bb45..18294641331 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/BooleanFieldSettingsDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/BooleanFieldSettingsDriver.cs @@ -1,3 +1,4 @@ +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.ContentFields.Fields; using OrchardCore.ContentManagement.Metadata.Models; @@ -10,7 +11,7 @@ public class BooleanFieldSettingsDriver : ContentPartFieldDefinitionDisplayDrive { public override IDisplayResult Edit(ContentPartFieldDefinition partFieldDefinition) { - return Initialize("BooleanFieldSettings_Edit", model => partFieldDefinition.PopulateSettings(model)) + return Copy("BooleanFieldSettings_Edit", partFieldDefinition.Settings.ToObject()) .Location("Content"); } diff --git a/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/DateFieldSettingsDriver.cs b/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/DateFieldSettingsDriver.cs index b2597da5692..8bd6e10263e 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/DateFieldSettingsDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/DateFieldSettingsDriver.cs @@ -1,3 +1,4 @@ +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.ContentFields.Fields; using OrchardCore.ContentManagement.Metadata.Models; @@ -10,7 +11,7 @@ public class DateFieldSettingsDriver : ContentPartFieldDefinitionDisplayDriver("DateFieldSettings_Edit", model => partFieldDefinition.PopulateSettings(model)) + return Copy("DateFieldSettings_Edit", partFieldDefinition.Settings.ToObject()) .Location("Content"); } diff --git a/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/DateTimeFieldSettingsDriver.cs b/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/DateTimeFieldSettingsDriver.cs index 2a4dbc139c9..42203f1eeab 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/DateTimeFieldSettingsDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/DateTimeFieldSettingsDriver.cs @@ -1,3 +1,4 @@ +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.ContentFields.Fields; using OrchardCore.ContentManagement.Metadata.Models; @@ -10,7 +11,7 @@ public class DateTimeFieldSettingsDriver : ContentPartFieldDefinitionDisplayDriv { public override IDisplayResult Edit(ContentPartFieldDefinition partFieldDefinition) { - return Initialize("DateTimeFieldSettings_Edit", model => partFieldDefinition.PopulateSettings(model)) + return Copy("DateTimeFieldSettings_Edit", partFieldDefinition.Settings.ToObject()) .Location("Content"); } diff --git a/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/LinkFieldSettingsDriver.cs b/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/LinkFieldSettingsDriver.cs index 551bd9370f7..aedf580b4b6 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/LinkFieldSettingsDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/LinkFieldSettingsDriver.cs @@ -1,3 +1,4 @@ +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.ContentFields.Fields; using OrchardCore.ContentManagement.Metadata.Models; @@ -10,7 +11,7 @@ public class LinkFieldSettingsDriver : ContentPartFieldDefinitionDisplayDriver("LinkFieldSettings_Edit", model => partFieldDefinition.PopulateSettings(model)) + return Copy("LinkFieldSettings_Edit", partFieldDefinition.Settings.ToObject()) .Location("Content"); } diff --git a/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/LocalizationSetContentPickerFieldSettingsDriver.cs b/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/LocalizationSetContentPickerFieldSettingsDriver.cs index f9383341b7a..df7c6ce71e9 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/LocalizationSetContentPickerFieldSettingsDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/LocalizationSetContentPickerFieldSettingsDriver.cs @@ -1,3 +1,4 @@ +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.ContentFields.Fields; using OrchardCore.ContentManagement.Metadata.Models; @@ -12,8 +13,8 @@ public class LocalizationSetContentPickerFieldSettingsDriver : ContentPartFieldD { public override IDisplayResult Edit(ContentPartFieldDefinition partFieldDefinition) { - return Initialize("LocalizationSetContentPickerFieldSettings_Edit", model => partFieldDefinition.PopulateSettings(model)) - .Location("Content"); + return Copy("LocalizationSetContentPickerFieldSettings_Edit", partFieldDefinition.Settings.ToObject()) + .Location("Content"); } public override async Task UpdateAsync(ContentPartFieldDefinition partFieldDefinition, UpdatePartFieldEditorContext context) diff --git a/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/NumericFieldSettingsDriver.cs b/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/NumericFieldSettingsDriver.cs index db007cb1bd8..35d74de4d3d 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/NumericFieldSettingsDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/NumericFieldSettingsDriver.cs @@ -1,3 +1,4 @@ +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.ContentFields.Fields; using OrchardCore.ContentManagement.Metadata.Models; @@ -10,7 +11,7 @@ public class NumericFieldSettingsDriver : ContentPartFieldDefinitionDisplayDrive { public override IDisplayResult Edit(ContentPartFieldDefinition partFieldDefinition) { - return Initialize("NumericFieldSettings_Edit", model => partFieldDefinition.PopulateSettings(model)) + return Copy("NumericFieldSettings_Edit", partFieldDefinition.Settings.ToObject()) .Location("Content"); } diff --git a/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/TextFieldSettingsDriver.cs b/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/TextFieldSettingsDriver.cs index 78d008477c5..4ead1d97898 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/TextFieldSettingsDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/TextFieldSettingsDriver.cs @@ -1,3 +1,4 @@ +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.ContentFields.Fields; using OrchardCore.ContentManagement.Metadata.Models; @@ -10,7 +11,7 @@ public class TextFieldSettingsDriver : ContentPartFieldDefinitionDisplayDriver("TextFieldSettings_Edit", model => partFieldDefinition.PopulateSettings(model)) + return Copy("TextFieldSettings_Edit", partFieldDefinition.Settings.ToObject()) .Location("Content"); } diff --git a/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/TimeFieldSettingsDriver.cs b/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/TimeFieldSettingsDriver.cs index 6eb32bd1d18..ce4c25322ba 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/TimeFieldSettingsDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/TimeFieldSettingsDriver.cs @@ -1,3 +1,4 @@ +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.ContentFields.Fields; using OrchardCore.ContentManagement.Metadata.Models; @@ -10,7 +11,7 @@ public class TimeFieldSettingsDriver : ContentPartFieldDefinitionDisplayDriver("TimeFieldSettings_Edit", model => partFieldDefinition.PopulateSettings(model)) + return Copy("TimeFieldSettings_Edit", partFieldDefinition.Settings.ToObject()) .Location("Content"); } diff --git a/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/YoutubeFieldSettingsDriver.cs b/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/YoutubeFieldSettingsDriver.cs index 38b2ca27679..9d9703fb540 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/YoutubeFieldSettingsDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentFields/Settings/YoutubeFieldSettingsDriver.cs @@ -1,3 +1,4 @@ +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.ContentFields.Fields; using OrchardCore.ContentManagement.Metadata.Models; @@ -10,12 +11,12 @@ public class YoutubeFieldSettingsDriver : ContentPartFieldDefinitionDisplayDrive { public override IDisplayResult Edit(ContentPartFieldDefinition partFieldDefinition) { - return Initialize("YoutubeFieldSetting_Edit", model => - { - partFieldDefinition.PopulateSettings(model); - model.Height = model.Height != default ? model.Height : 315; - model.Width = model.Width != default ? model.Width : 560; - }).Location("Content"); + var model = partFieldDefinition.Settings.ToObject(); + model.Height = model.Height != default ? model.Height : 315; + model.Width = model.Width != default ? model.Width : 560; + + return Copy("YoutubeFieldSetting_Edit", model) + .Location("Content"); } public async override Task UpdateAsync(ContentPartFieldDefinition partFieldDefinition, UpdatePartFieldEditorContext context) diff --git a/src/OrchardCore.Modules/OrchardCore.ContentTypes/RecipeSteps/ContentDefinitionStep.cs b/src/OrchardCore.Modules/OrchardCore.ContentTypes/RecipeSteps/ContentDefinitionStep.cs index a0f464a68b3..f6f9ee78c87 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentTypes/RecipeSteps/ContentDefinitionStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentTypes/RecipeSteps/ContentDefinitionStep.cs @@ -1,4 +1,5 @@ using System; +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.ContentManagement.Metadata; using OrchardCore.ContentManagement.Metadata.Models; diff --git a/src/OrchardCore.Modules/OrchardCore.ContentTypes/RecipeSteps/DeleteContentDefinitionStep.cs b/src/OrchardCore.Modules/OrchardCore.ContentTypes/RecipeSteps/DeleteContentDefinitionStep.cs index ac5f136bad0..1cab40a1bb5 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentTypes/RecipeSteps/DeleteContentDefinitionStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentTypes/RecipeSteps/DeleteContentDefinitionStep.cs @@ -1,4 +1,5 @@ using System; +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.ContentManagement.Metadata; using OrchardCore.Recipes.Models; diff --git a/src/OrchardCore.Modules/OrchardCore.ContentTypes/RecipeSteps/ReplaceContentDefinitionStep.cs b/src/OrchardCore.Modules/OrchardCore.ContentTypes/RecipeSteps/ReplaceContentDefinitionStep.cs index 421abb92728..07d40f4f897 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentTypes/RecipeSteps/ReplaceContentDefinitionStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentTypes/RecipeSteps/ReplaceContentDefinitionStep.cs @@ -1,4 +1,5 @@ using System; +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.ContentManagement.Metadata; using OrchardCore.ContentManagement.Metadata.Records; diff --git a/src/OrchardCore.Modules/OrchardCore.ContentTypes/Recipes/LuceneRecipeEventHandler.cs b/src/OrchardCore.Modules/OrchardCore.ContentTypes/Recipes/LuceneRecipeEventHandler.cs index 82e8828744b..9d9d61823a0 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentTypes/Recipes/LuceneRecipeEventHandler.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentTypes/Recipes/LuceneRecipeEventHandler.cs @@ -1,6 +1,6 @@ using System; +using System.Text.Json.Nodes; using System.Threading.Tasks; -using Newtonsoft.Json.Linq; using OrchardCore.ContentManagement.Metadata.Records; using OrchardCore.Recipes.Events; using OrchardCore.Recipes.Models; @@ -34,10 +34,10 @@ public Task RecipeStepExecutingAsync(RecipeExecutionContext context) { if (partDefinition.Settings != null) { - if (partDefinition.Settings.TryGetValue("ContentIndexSettings", out var existingPartSettings) && + if (partDefinition.Settings.TryGetPropertyValue("ContentIndexSettings", out var existingPartSettings) && !partDefinition.Settings.ContainsKey("LuceneContentIndexSettings")) { - partDefinition.Settings.Add(new JProperty("LuceneContentIndexSettings", existingPartSettings)); + partDefinition.Settings.Add("LuceneContentIndexSettings", existingPartSettings); } partDefinition.Settings.Remove("ContentIndexSettings"); @@ -49,10 +49,10 @@ public Task RecipeStepExecutingAsync(RecipeExecutionContext context) { if (partDefinition.Settings != null) { - if (partDefinition.Settings.TryGetValue("ContentIndexSettings", out var existingPartSettings) && + if (partDefinition.Settings.TryGetPropertyValue("ContentIndexSettings", out var existingPartSettings) && !partDefinition.Settings.ContainsKey("LuceneContentIndexSettings")) { - partDefinition.Settings.Add(new JProperty("LuceneContentIndexSettings", existingPartSettings)); + partDefinition.Settings.Add("LuceneContentIndexSettings", existingPartSettings); } partDefinition.Settings.Remove("ContentIndexSettings"); @@ -61,10 +61,10 @@ public Task RecipeStepExecutingAsync(RecipeExecutionContext context) { if (fieldDefinition.Settings != null) { - if (fieldDefinition.Settings.TryGetValue("ContentIndexSettings", out var existingFieldSettings) && + if (fieldDefinition.Settings.TryGetPropertyValue("ContentIndexSettings", out var existingFieldSettings) && !fieldDefinition.Settings.ContainsKey("LuceneContentIndexSettings")) { - fieldDefinition.Settings.Add(new JProperty("LuceneContentIndexSettings", existingFieldSettings)); + fieldDefinition.Settings.Add("LuceneContentIndexSettings", existingFieldSettings); } fieldDefinition.Settings.Remove("ContentIndexSettings"); diff --git a/src/OrchardCore.Modules/OrchardCore.ContentTypes/ViewModels/EditTypeViewModel.cs b/src/OrchardCore.Modules/OrchardCore.ContentTypes/ViewModels/EditTypeViewModel.cs index 60ef0bac230..717089f6666 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentTypes/ViewModels/EditTypeViewModel.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentTypes/ViewModels/EditTypeViewModel.cs @@ -1,5 +1,5 @@ +using System.Text.Json.Nodes; using Microsoft.AspNetCore.Mvc.ModelBinding; -using Newtonsoft.Json.Linq; using OrchardCore.ContentManagement.Metadata.Models; namespace OrchardCore.ContentTypes.ViewModels @@ -8,7 +8,7 @@ public class EditTypeViewModel { public EditTypeViewModel() { - Settings = new JObject(); + Settings = new JsonObject(); } public EditTypeViewModel(ContentTypeDefinition contentTypeDefinition) @@ -25,7 +25,7 @@ public EditTypeViewModel(ContentTypeDefinition contentTypeDefinition) public string[] OrderedPartNames { get; set; } [BindNever] - public JObject Settings { get; set; } + public JsonObject Settings { get; set; } [BindNever] public ContentTypeDefinition TypeDefinition { get; set; } diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Controllers/ApiController.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Controllers/ApiController.cs index f11bbfb15dc..e6d4eccc00d 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Controllers/ApiController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Controllers/ApiController.cs @@ -143,7 +143,7 @@ public async Task Post(ContentItem model, bool draft = false) return this.ChallengeOrForbid("Api"); } - contentItem.Merge(model, _updateJsonMergeSettings); + contentItem.Merge(model); // , _updateJsonMergeSettings); await _contentManager.UpdateAsync(contentItem); var result = await _contentManager.ValidateAsync(contentItem); diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Recipes/ContentStep.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Recipes/ContentStep.cs index c1c100ee6bd..f59787d0cd6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Recipes/ContentStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Recipes/ContentStep.cs @@ -1,7 +1,7 @@ using System; +using System.Text.Json.Nodes; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; -using Newtonsoft.Json.Linq; using OrchardCore.ContentManagement; using OrchardCore.Environment.Shell.Scope; using OrchardCore.Recipes.Models; @@ -45,6 +45,6 @@ public Task ExecuteAsync(RecipeExecutionContext context) public class ContentStepModel { - public JArray Data { get; set; } + public JsonArray Data { get; set; } } } diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Scripting/ContentMethodsProvider.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Scripting/ContentMethodsProvider.cs index e837d307de3..4ec49903406 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Scripting/ContentMethodsProvider.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Scripting/ContentMethodsProvider.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using Microsoft.Extensions.DependencyInjection; -using Newtonsoft.Json.Linq; using OrchardCore.ContentManagement; using OrchardCore.Scripting; @@ -55,7 +54,7 @@ public ContentMethodsProvider() Method = serviceProvider => (Action)((contentItem, properties) => { var contentManager = serviceProvider.GetRequiredService(); - contentItem.Merge(properties, new JsonMergeSettings { MergeArrayHandling = MergeArrayHandling.Replace }); + contentItem.Merge(properties); // , new JsonMergeSettings { MergeArrayHandling = MergeArrayHandling.Replace }); contentManager.UpdateAsync(contentItem).GetAwaiter().GetResult(); var result = contentManager.ValidateAsync(contentItem).GetAwaiter().GetResult(); if (!result.Succeeded) diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Activities/UpdateContentTask.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Activities/UpdateContentTask.cs index 1400758cab5..25454cb7245 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Activities/UpdateContentTask.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Workflows/Activities/UpdateContentTask.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; using System.Text.Encodings.Web; +using System.Text.Json; +using System.Text.Json.Nodes; using System.Threading.Tasks; using Microsoft.Extensions.Localization; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Workflows; using OrchardCore.DisplayManagement.ModelBinding; @@ -56,7 +56,11 @@ public WorkflowExpression ContentItemIdExpression public WorkflowExpression ContentProperties { - get => GetProperty(() => new WorkflowExpression(JsonConvert.SerializeObject(new { DisplayText = S["Enter a title"].Value }, Formatting.Indented))); + get => GetProperty(() => + //new WorkflowExpression(JsonConvert.SerializeObject(new { DisplayText = S["Enter a title"].Value }, Formatting.Indented))); + new WorkflowExpression(JsonSerializer.Serialize(new { DisplayText = S["Enter a title"].Value }))); + + set => SetProperty(value); } @@ -122,7 +126,7 @@ public async override Task ExecuteAsync(WorkflowExecuti if (!string.IsNullOrWhiteSpace(ContentProperties.Expression)) { var contentProperties = await _expressionEvaluator.EvaluateAsync(ContentProperties, workflowContext, _javaScriptEncoder); - contentItem.Merge(JObject.Parse(contentProperties), new JsonMergeSettings { MergeArrayHandling = MergeArrayHandling.Replace }); + contentItem.Merge(JsonNode.Parse(contentProperties)); // , new JsonMergeSettings { MergeArrayHandling = MergeArrayHandling.Replace }); } if (!inlineEventOfSameContentItemId) diff --git a/src/OrchardCore.Modules/OrchardCore.Cors/Services/CorsService.cs b/src/OrchardCore.Modules/OrchardCore.Cors/Services/CorsService.cs index 5e106fc28c5..17dc0c6e93e 100644 --- a/src/OrchardCore.Modules/OrchardCore.Cors/Services/CorsService.cs +++ b/src/OrchardCore.Modules/OrchardCore.Cors/Services/CorsService.cs @@ -1,5 +1,5 @@ +using System.Text.Json.Nodes; using System.Threading.Tasks; -using Newtonsoft.Json.Linq; using OrchardCore.Cors.Settings; using OrchardCore.Entities; using OrchardCore.Settings; diff --git a/src/OrchardCore.Modules/OrchardCore.CustomSettings/Drivers/CustomSettingsDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.CustomSettings/Drivers/CustomSettingsDisplayDriver.cs index 4cf6d6bb21a..d0465cd3292 100644 --- a/src/OrchardCore.Modules/OrchardCore.CustomSettings/Drivers/CustomSettingsDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.CustomSettings/Drivers/CustomSettingsDisplayDriver.cs @@ -1,5 +1,5 @@ +using System.Text.Json.Nodes; using System.Threading.Tasks; -using Newtonsoft.Json.Linq; using OrchardCore.ContentManagement.Display; using OrchardCore.CustomSettings.Services; using OrchardCore.CustomSettings.ViewModels; diff --git a/src/OrchardCore.Modules/OrchardCore.CustomSettings/Recipes/CustomSettingsStep.cs b/src/OrchardCore.Modules/OrchardCore.CustomSettings/Recipes/CustomSettingsStep.cs index d156fc4bfd6..76b1aa8c7d5 100644 --- a/src/OrchardCore.Modules/OrchardCore.CustomSettings/Recipes/CustomSettingsStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.CustomSettings/Recipes/CustomSettingsStep.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using System.Threading.Tasks; using OrchardCore.Recipes.Models; using OrchardCore.Recipes.Services; @@ -26,17 +25,17 @@ public async Task ExecuteAsync(RecipeExecutionContext context) return; } - var model = context.Step; - - var customSettingsList = (from property in model.Properties() - where property.Name != "name" - select property).ToArray(); - var siteSettings = await _siteService.LoadSiteSettingsAsync(); - foreach (var customSettings in customSettingsList) + var model = context.Step; + foreach (var customSettings in model) { - siteSettings.Properties[customSettings.Name] = customSettings.Value; + if (customSettings.Key == "name") + { + continue; + } + + siteSettings.Properties[customSettings.Key] = customSettings.Value; } await _siteService.UpdateSiteSettingsAsync(siteSettings); diff --git a/src/OrchardCore.Modules/OrchardCore.CustomSettings/Services/CustomSettingsService.cs b/src/OrchardCore.Modules/OrchardCore.CustomSettings/Services/CustomSettingsService.cs index 6be5708738b..c5207c6e110 100644 --- a/src/OrchardCore.Modules/OrchardCore.CustomSettings/Services/CustomSettingsService.cs +++ b/src/OrchardCore.Modules/OrchardCore.CustomSettings/Services/CustomSettingsService.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text.Json.Nodes; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; -using Newtonsoft.Json.Linq; using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Metadata; using OrchardCore.ContentManagement.Metadata.Models; @@ -98,10 +98,10 @@ public async Task GetSettingsAsync(ContentTypeDefinition settingsTy public async Task GetSettingsAsync(ISite site, ContentTypeDefinition settingsType, Action isNew = null) { - JToken property; + JsonNode property; ContentItem contentItem; - if (site.Properties.TryGetValue(settingsType.Name, out property)) + if (site.Properties.TryGetPropertyValue(settingsType.Name, out property)) { var existing = property.ToObject(); diff --git a/src/OrchardCore.Modules/OrchardCore.Deployment/Recipes/DeploymentPlansRecipeStep.cs b/src/OrchardCore.Modules/OrchardCore.Deployment/Recipes/DeploymentPlansRecipeStep.cs index e2cd3eec9a9..22af8f5010b 100644 --- a/src/OrchardCore.Modules/OrchardCore.Deployment/Recipes/DeploymentPlansRecipeStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Deployment/Recipes/DeploymentPlansRecipeStep.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text.Json.Nodes; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; -using Newtonsoft.Json.Linq; using OrchardCore.Recipes.Models; using OrchardCore.Recipes.Services; @@ -90,7 +90,7 @@ private class DeploymentStepModel { public string Type { get; set; } - public JObject Step { get; set; } + public JsonObject Step { get; set; } } } } diff --git a/src/OrchardCore.Modules/OrchardCore.Facebook/Login/Recipes/FacebookLoginSettingsStep.cs b/src/OrchardCore.Modules/OrchardCore.Facebook/Login/Recipes/FacebookLoginSettingsStep.cs index 029cac8abc5..46e45966562 100644 --- a/src/OrchardCore.Modules/OrchardCore.Facebook/Login/Recipes/FacebookLoginSettingsStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Facebook/Login/Recipes/FacebookLoginSettingsStep.cs @@ -1,4 +1,5 @@ using System; +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.Facebook.Login.Services; using OrchardCore.Facebook.Login.Settings; diff --git a/src/OrchardCore.Modules/OrchardCore.Facebook/Login/Services/FacebookLoginService.cs b/src/OrchardCore.Modules/OrchardCore.Facebook/Login/Services/FacebookLoginService.cs index 7c584b421d0..718729feeb8 100644 --- a/src/OrchardCore.Modules/OrchardCore.Facebook/Login/Services/FacebookLoginService.cs +++ b/src/OrchardCore.Modules/OrchardCore.Facebook/Login/Services/FacebookLoginService.cs @@ -2,8 +2,8 @@ using System.Collections.Generic; using System.Collections.Immutable; using System.ComponentModel.DataAnnotations; +using System.Text.Json.Nodes; using System.Threading.Tasks; -using Newtonsoft.Json.Linq; using OrchardCore.Entities; using OrchardCore.Facebook.Login.Settings; using OrchardCore.Settings; diff --git a/src/OrchardCore.Modules/OrchardCore.Facebook/Recipes/FacebookSettingsStep.cs b/src/OrchardCore.Modules/OrchardCore.Facebook/Recipes/FacebookSettingsStep.cs index 93a56e7bb1a..4ddaec0e112 100644 --- a/src/OrchardCore.Modules/OrchardCore.Facebook/Recipes/FacebookSettingsStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Facebook/Recipes/FacebookSettingsStep.cs @@ -1,4 +1,5 @@ using System; +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.Facebook.Services; using OrchardCore.Recipes.Models; diff --git a/src/OrchardCore.Modules/OrchardCore.Facebook/Services/FacebookService.cs b/src/OrchardCore.Modules/OrchardCore.Facebook/Services/FacebookService.cs index b80a556c6d2..98a7658dc44 100644 --- a/src/OrchardCore.Modules/OrchardCore.Facebook/Services/FacebookService.cs +++ b/src/OrchardCore.Modules/OrchardCore.Facebook/Services/FacebookService.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.Text.Json.Nodes; using System.Threading.Tasks; using Microsoft.Extensions.Localization; -using Newtonsoft.Json.Linq; using OrchardCore.Entities; using OrchardCore.Facebook.Settings; using OrchardCore.Settings; diff --git a/src/OrchardCore.Modules/OrchardCore.Features/Recipes/Executors/FeatureStep.cs b/src/OrchardCore.Modules/OrchardCore.Features/Recipes/Executors/FeatureStep.cs index b3b8e13fea9..26a7f701851 100644 --- a/src/OrchardCore.Modules/OrchardCore.Features/Recipes/Executors/FeatureStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Features/Recipes/Executors/FeatureStep.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.Environment.Shell; using OrchardCore.Recipes.Models; diff --git a/src/OrchardCore.Modules/OrchardCore.GitHub/Recipes/GithubAuthenticationSettingsStep.cs b/src/OrchardCore.Modules/OrchardCore.GitHub/Recipes/GithubAuthenticationSettingsStep.cs index 290de627701..4ed64ade22f 100644 --- a/src/OrchardCore.Modules/OrchardCore.GitHub/Recipes/GithubAuthenticationSettingsStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.GitHub/Recipes/GithubAuthenticationSettingsStep.cs @@ -1,4 +1,5 @@ using System; +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.GitHub.Services; using OrchardCore.GitHub.Settings; diff --git a/src/OrchardCore.Modules/OrchardCore.Layers/Recipes/LayerStep.cs b/src/OrchardCore.Modules/OrchardCore.Layers/Recipes/LayerStep.cs index fd9988378c4..6bac6681691 100644 --- a/src/OrchardCore.Modules/OrchardCore.Layers/Recipes/LayerStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Layers/Recipes/LayerStep.cs @@ -1,9 +1,8 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text.Json.Nodes; using System.Threading.Tasks; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using OrchardCore.Layers.Models; using OrchardCore.Layers.Services; using OrchardCore.Recipes.Models; @@ -17,10 +16,10 @@ namespace OrchardCore.Layers.Recipes /// public class LayerStep : IRecipeStepHandler { - private readonly static JsonSerializer _jsonSerializer = new() - { - TypeNameHandling = TypeNameHandling.Auto, - }; + // private readonly static JsonSerializer _jsonSerializer = new() + // { + // TypeNameHandling = TypeNameHandling.Auto, + // }; private readonly ILayerService _layerService; private readonly IRuleMigrator _ruleMigrator; @@ -94,7 +93,7 @@ public async Task ExecuteAsync(RecipeExecutionContext context) var name = jCondition["Name"].ToString(); if (factories.TryGetValue(name, out var factory)) { - var factoryCondition = (Condition)jCondition.ToObject(factory.Create().GetType(), _jsonSerializer); + var factoryCondition = (Condition)jCondition.ToObject(factory.Create().GetType()/*, _jsonSerializer*/); layer.LayerRule.Conditions.Add(factoryCondition); } @@ -149,6 +148,6 @@ public class RuleStepModel { public string Name { get; set; } public string ConditionId { get; set; } - public JArray Conditions { get; set; } + public JsonArray Conditions { get; set; } } } diff --git a/src/OrchardCore.Modules/OrchardCore.Media/Recipes/MediaProfileStep.cs b/src/OrchardCore.Modules/OrchardCore.Media/Recipes/MediaProfileStep.cs index 247581e092b..cf0de970f68 100644 --- a/src/OrchardCore.Modules/OrchardCore.Media/Recipes/MediaProfileStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Media/Recipes/MediaProfileStep.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.Media.Models; using OrchardCore.Media.Services; diff --git a/src/OrchardCore.Modules/OrchardCore.Media/Recipes/MediaStep.cs b/src/OrchardCore.Modules/OrchardCore.Media/Recipes/MediaStep.cs index 6234f883e10..fbd0b64a4fd 100644 --- a/src/OrchardCore.Modules/OrchardCore.Media/Recipes/MediaStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Media/Recipes/MediaStep.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using System.Net.Http; +using System.Text.Json.Nodes; using System.Threading.Tasks; using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Logging; diff --git a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Recipes/AzureADSettingsStep.cs b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Recipes/AzureADSettingsStep.cs index db775ba1fe3..30a56777d61 100644 --- a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Recipes/AzureADSettingsStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Recipes/AzureADSettingsStep.cs @@ -1,4 +1,5 @@ using System; +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.Microsoft.Authentication.Services; using OrchardCore.Microsoft.Authentication.Settings; diff --git a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Recipes/MicrosoftAccountSettingsStep.cs b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Recipes/MicrosoftAccountSettingsStep.cs index afccf61b1d2..642dce35fed 100644 --- a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Recipes/MicrosoftAccountSettingsStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Recipes/MicrosoftAccountSettingsStep.cs @@ -1,4 +1,5 @@ using System; +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.Microsoft.Authentication.Services; using OrchardCore.Microsoft.Authentication.Settings; diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Recipes/OpenIdApplicationStep.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Recipes/OpenIdApplicationStep.cs index 0f7ef4d64c7..999d3682993 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Recipes/OpenIdApplicationStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Recipes/OpenIdApplicationStep.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.OpenId.Abstractions.Managers; using OrchardCore.Recipes.Models; diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Recipes/OpenIdClientSettingsStep.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Recipes/OpenIdClientSettingsStep.cs index 4742093198f..942b245aaeb 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Recipes/OpenIdClientSettingsStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Recipes/OpenIdClientSettingsStep.cs @@ -1,4 +1,5 @@ using System; +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.OpenId.Services; using OrchardCore.OpenId.Settings; diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Recipes/OpenIdScopeStep.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Recipes/OpenIdScopeStep.cs index 6ede2d9ef3b..7974664825c 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Recipes/OpenIdScopeStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Recipes/OpenIdScopeStep.cs @@ -1,4 +1,5 @@ using System; +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.OpenId.Abstractions.Descriptors; using OrchardCore.OpenId.Abstractions.Managers; diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Recipes/OpenIdServerSettingsStep.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Recipes/OpenIdServerSettingsStep.cs index 9ee0c9dc74c..fc40623cb37 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Recipes/OpenIdServerSettingsStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Recipes/OpenIdServerSettingsStep.cs @@ -1,4 +1,5 @@ using System; +using System.Text.Json.Nodes; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using OrchardCore.OpenId.Services; diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Recipes/OpenIdValidationSettingsStep.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Recipes/OpenIdValidationSettingsStep.cs index 650ca2d0597..e305181a7ca 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Recipes/OpenIdValidationSettingsStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Recipes/OpenIdValidationSettingsStep.cs @@ -1,4 +1,5 @@ using System; +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.OpenId.Services; using OrchardCore.OpenId.Settings; diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Services/OpenIdClientService.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Services/OpenIdClientService.cs index 01ee51d8282..2d9ab906ba0 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Services/OpenIdClientService.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Services/OpenIdClientService.cs @@ -1,10 +1,10 @@ using System; using System.Collections.Immutable; using System.ComponentModel.DataAnnotations; +using System.Text.Json.Nodes; using System.Threading.Tasks; using Microsoft.Extensions.Localization; using Microsoft.IdentityModel.Protocols.OpenIdConnect; -using Newtonsoft.Json.Linq; using OrchardCore.Entities; using OrchardCore.OpenId.Settings; using OrchardCore.Settings; diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Services/OpenIdServerService.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Services/OpenIdServerService.cs index 28bf8cf2782..0e308ba27cd 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Services/OpenIdServerService.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Services/OpenIdServerService.cs @@ -7,6 +7,7 @@ using System.Runtime.InteropServices; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; +using System.Text.Json.Nodes; using System.Threading.Tasks; using Microsoft.AspNetCore.DataProtection; using Microsoft.Extensions.Caching.Memory; @@ -14,7 +15,6 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.IdentityModel.Tokens; -using Newtonsoft.Json.Linq; using OrchardCore.Environment.Shell; using OrchardCore.OpenId.Settings; using OrchardCore.Settings; @@ -63,7 +63,7 @@ public async Task LoadSettingsAsync() private OpenIdServerSettings GetSettingsFromContainer(ISite container) { - if (container.Properties.TryGetValue(nameof(OpenIdServerSettings), out var settings)) + if (container.Properties.TryGetPropertyValue(nameof(OpenIdServerSettings), out var settings)) { return settings.ToObject(); } diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Services/OpenIdValidationService.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Services/OpenIdValidationService.cs index 765e5f9adfc..bc78bea7a85 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Services/OpenIdValidationService.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Services/OpenIdValidationService.cs @@ -2,11 +2,11 @@ using System.Collections.Immutable; using System.ComponentModel.DataAnnotations; using System.Linq; +using System.Text.Json.Nodes; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Localization; using Microsoft.Extensions.Options; -using Newtonsoft.Json.Linq; using OpenIddict.Server; using OrchardCore.Environment.Shell; using OrchardCore.Environment.Shell.Descriptor.Models; @@ -52,7 +52,7 @@ public async Task LoadSettingsAsync() private OpenIdValidationSettings GetSettingsFromContainer(ISite container) { - if (container.Properties.TryGetValue(nameof(OpenIdValidationSettings), out var settings)) + if (container.Properties.TryGetPropertyValue(nameof(OpenIdValidationSettings), out var settings)) { return settings.ToObject(); } diff --git a/src/OrchardCore.Modules/OrchardCore.Placements/Recipes/PlacementStep.cs b/src/OrchardCore.Modules/OrchardCore.Placements/Recipes/PlacementStep.cs index ee63bbadc66..a07894ada91 100644 --- a/src/OrchardCore.Modules/OrchardCore.Placements/Recipes/PlacementStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Placements/Recipes/PlacementStep.cs @@ -1,6 +1,6 @@ using System; +using System.Text.Json.Nodes; using System.Threading.Tasks; -using Newtonsoft.Json.Linq; using OrchardCore.DisplayManagement.Descriptors.ShapePlacementStrategy; using OrchardCore.Placements.Services; using OrchardCore.Recipes.Models; @@ -27,11 +27,11 @@ public async Task ExecuteAsync(RecipeExecutionContext context) return; } - if (context.Step.Property("Placements").Value is JObject templates) + if (context.Step.TryGetPropertyValue("Placements", out var jsonNode) && jsonNode is JsonObject templates) { - foreach (var property in templates.Properties()) + foreach (var property in templates) { - var name = property.Name; + var name = property.Key; var value = property.Value.ToObject(); await _placementsManager.UpdateShapePlacementsAsync(name, value); diff --git a/src/OrchardCore.Modules/OrchardCore.Queries/Recipes/QueryStep.cs b/src/OrchardCore.Modules/OrchardCore.Queries/Recipes/QueryStep.cs index 5c031807502..56f988b7913 100644 --- a/src/OrchardCore.Modules/OrchardCore.Queries/Recipes/QueryStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Queries/Recipes/QueryStep.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text.Json.Nodes; using System.Threading.Tasks; using Microsoft.Extensions.Logging; -using Newtonsoft.Json.Linq; using OrchardCore.Recipes.Models; using OrchardCore.Recipes.Services; @@ -37,7 +37,7 @@ public async Task ExecuteAsync(RecipeExecutionContext context) var model = context.Step.ToObject(); - foreach (var token in model.Queries.Cast()) + foreach (var token in model.Queries.Cast()) { var sourceName = token[nameof(Query.Source)].ToString(); var sample = _querySources.FirstOrDefault(x => x.Name == sourceName)?.Create(); @@ -57,6 +57,6 @@ public async Task ExecuteAsync(RecipeExecutionContext context) public class QueryStepModel { - public JArray Queries { get; set; } + public JsonArray Queries { get; set; } } } diff --git a/src/OrchardCore.Modules/OrchardCore.Recipes/RecipeSteps/CommandStep.cs b/src/OrchardCore.Modules/OrchardCore.Recipes/RecipeSteps/CommandStep.cs index 034fbe4f876..0a98156f2bc 100644 --- a/src/OrchardCore.Modules/OrchardCore.Recipes/RecipeSteps/CommandStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Recipes/RecipeSteps/CommandStep.cs @@ -1,4 +1,5 @@ using System; +using System.Text.Json.Nodes; using System.Threading.Tasks; using Cysharp.Text; using Microsoft.Extensions.Logging; diff --git a/src/OrchardCore.Modules/OrchardCore.Recipes/RecipeSteps/RecipesStep.cs b/src/OrchardCore.Modules/OrchardCore.Recipes/RecipeSteps/RecipesStep.cs index 2ab4673e51d..5e7f900cdbf 100644 --- a/src/OrchardCore.Modules/OrchardCore.Recipes/RecipeSteps/RecipesStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Recipes/RecipeSteps/RecipesStep.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.Recipes.Models; using OrchardCore.Recipes.Services; diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/Recipes/RolesStep.cs b/src/OrchardCore.Modules/OrchardCore.Roles/Recipes/RolesStep.cs index e0bc02a9745..22368501705 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/Recipes/RolesStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Roles/Recipes/RolesStep.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using System.Text.Json.Nodes; using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using OrchardCore.Recipes.Models; diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentPickerFieldElasticEditorSettingsDriver.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentPickerFieldElasticEditorSettingsDriver.cs index db6e8adb42c..c2656a5dc97 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentPickerFieldElasticEditorSettingsDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Drivers/ContentPickerFieldElasticEditorSettingsDriver.cs @@ -1,8 +1,9 @@ -using System; using System.Linq; +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.ContentTypes.Editors; +using OrchardCore.DisplayManagement.Handlers; using OrchardCore.DisplayManagement.Views; using OrchardCore.Search.Elasticsearch.Core.Models; using OrchardCore.Search.Elasticsearch.Core.Services; @@ -18,13 +19,13 @@ public ContentPickerFieldElasticEditorSettingsDriver(ElasticIndexSettingsService _elasticIndexSettingsService = elasticIndexSettingsService; } - public override IDisplayResult Edit(ContentPartFieldDefinition partFieldDefinition) + public override async Task EditAsync(ContentPartFieldDefinition partFieldDefinition, BuildEditorContext context) { - return Initialize("ContentPickerFieldElasticEditorSettings_Edit", async model => - { - partFieldDefinition.PopulateSettings(model); - model.Indices = (await _elasticIndexSettingsService.GetSettingsAsync()).Select(x => x.IndexName).ToArray(); - }).Location("Editor"); + var model = partFieldDefinition.Settings.ToObject(); + model.Indices = (await _elasticIndexSettingsService.GetSettingsAsync()).Select(x => x.IndexName).ToArray(); + + return Copy("ContentPickerFieldElasticEditorSettings_Edit", model) + .Location("Editor"); } public override async Task UpdateAsync(ContentPartFieldDefinition partFieldDefinition, UpdatePartFieldEditorContext context) @@ -38,7 +39,7 @@ public override async Task UpdateAsync(ContentPartFieldDefinitio context.Builder.WithSettings(model); } - return Edit(partFieldDefinition); + return await EditAsync(partFieldDefinition, context); } public override bool CanHandleModel(ContentPartFieldDefinition model) diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Migrations.cs b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Migrations.cs index 64c9021ce46..7969affa797 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Migrations.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Migrations.cs @@ -1,8 +1,8 @@ using System; +using System.Text.Json.Nodes; using Dapper; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using Newtonsoft.Json.Linq; using OrchardCore.ContentManagement.Metadata; using OrchardCore.Data; using OrchardCore.Data.Migration; @@ -31,7 +31,7 @@ public int Create() { _contentDefinitionManager.AlterPartDefinition(partDefinition.Name, partBuilder => { - if (partDefinition.Settings.TryGetValue("ContentIndexSettings", out var existingPartSettings) && + if (partDefinition.Settings.TryGetPropertyValue("ContentIndexSettings", out var existingPartSettings) && !partDefinition.Settings.ContainsKey(nameof(LuceneContentIndexSettings))) { var included = existingPartSettings["Included"]; @@ -55,12 +55,13 @@ public int Create() } } - // We remove unecessary properties from old releases. - existingPartSettings["Analyzed"]?.Parent.Remove(); - existingPartSettings["Tokenized"]?.Parent.Remove(); - existingPartSettings["Template"]?.Parent.Remove(); + // We remove unnecessary properties from old releases. + // existingPartSettings["Analyzed"]?.Parent.Remove(); + // existingPartSettings["Tokenized"]?.Parent.Remove(); + // existingPartSettings["Template"]?.Parent.Remove(); - partDefinition.Settings.Add(new JProperty(nameof(LuceneContentIndexSettings), existingPartSettings)); + var jExistingPartSettings = new JsonObject(existingPartSettings.AsObject()); + partDefinition.Settings.Add(nameof(LuceneContentIndexSettings), jExistingPartSettings); } partDefinition.Settings.Remove("ContentIndexSettings"); @@ -74,7 +75,7 @@ public int Create() { _contentDefinitionManager.AlterPartDefinition(partDefinition.Name, partBuilder => { - if (partDefinition.Settings.TryGetValue("ContentIndexSettings", out var existingPartSettings) && + if (partDefinition.Settings.TryGetPropertyValue("ContentIndexSettings", out var existingPartSettings) && !partDefinition.Settings.ContainsKey(nameof(LuceneContentIndexSettings))) { var included = existingPartSettings["Included"]; @@ -98,20 +99,21 @@ public int Create() } } - // We remove unecessary properties from old releases. - existingPartSettings["Analyzed"]?.Parent.Remove(); - existingPartSettings["Tokenized"]?.Parent.Remove(); - existingPartSettings["Template"]?.Parent.Remove(); + // We remove unnecessary properties from old releases. + // existingPartSettings["Analyzed"]?.Parent.Remove(); + // existingPartSettings["Tokenized"]?.Parent.Remove(); + // existingPartSettings["Template"]?.Parent.Remove(); - partDefinition.Settings.Add(new JProperty(nameof(LuceneContentIndexSettings), existingPartSettings)); + var jExistingPartSettings = new JsonObject(existingPartSettings.AsObject()); + partDefinition.Settings.Add(nameof(LuceneContentIndexSettings), jExistingPartSettings); } partDefinition.Settings.Remove("ContentIndexSettings"); foreach (var fieldDefinition in partDefinition.Fields) { - if (fieldDefinition.Settings.TryGetValue("ContentIndexSettings", out var existingFieldSettings) - && !fieldDefinition.Settings.TryGetValue(nameof(LuceneContentIndexSettings), out var existingLuceneFieldSettings)) + if (fieldDefinition.Settings.TryGetPropertyValue("ContentIndexSettings", out var existingFieldSettings) + && !fieldDefinition.Settings.TryGetPropertyValue(nameof(LuceneContentIndexSettings), out _)) { var included = existingFieldSettings["Included"]; var analyzed = existingFieldSettings["Analyzed"]; @@ -134,12 +136,13 @@ public int Create() } } - // We remove unecessary properties from old releases. - existingFieldSettings["Analyzed"]?.Parent.Remove(); - existingFieldSettings["Tokenized"]?.Parent.Remove(); - existingFieldSettings["Template"]?.Parent.Remove(); + // We remove unnecessary properties from old releases. + // existingFieldSettings["Analyzed"]?.Parent.Remove(); + // existingFieldSettings["Tokenized"]?.Parent.Remove(); + // existingFieldSettings["Template"]?.Parent.Remove(); - fieldDefinition.Settings.Add(new JProperty(nameof(LuceneContentIndexSettings), existingFieldSettings)); + var jExistingFieldSettings = new JsonObject(existingFieldSettings.AsObject()); + fieldDefinition.Settings.Add(nameof(LuceneContentIndexSettings), jExistingFieldSettings); } fieldDefinition.Settings.Remove("ContentIndexSettings"); diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Recipes/LuceneIndexRebuildStep.cs b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Recipes/LuceneIndexRebuildStep.cs index dd1b476f1de..458dbde71ab 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Recipes/LuceneIndexRebuildStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Recipes/LuceneIndexRebuildStep.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using System.Text.Json.Nodes; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using OrchardCore.BackgroundJobs; diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Recipes/LuceneIndexResetStep.cs b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Recipes/LuceneIndexResetStep.cs index ab4fffae74f..b0f320e8c19 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Recipes/LuceneIndexResetStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Recipes/LuceneIndexResetStep.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using System.Text.Json.Nodes; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using OrchardCore.BackgroundJobs; diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Recipes/LuceneIndexStep.cs b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Recipes/LuceneIndexStep.cs index dc2dec2d0fb..0dd0611145c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Recipes/LuceneIndexStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Recipes/LuceneIndexStep.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text.Json.Nodes; using System.Threading.Tasks; -using Newtonsoft.Json.Linq; using OrchardCore.Recipes.Models; using OrchardCore.Recipes.Services; using OrchardCore.Search.Lucene.Model; @@ -34,9 +34,9 @@ public async Task ExecuteAsync(RecipeExecutionContext context) } var indices = context.Step["Indices"]; - if (indices != null) + if (indices is JsonArray jsonArray) { - foreach (var index in indices) + foreach (var index in jsonArray) { var luceneIndexSettings = index.ToObject>().FirstOrDefault(); @@ -52,6 +52,6 @@ public async Task ExecuteAsync(RecipeExecutionContext context) public class ContentStepModel { - public JObject Data { get; set; } + public JsonObject Data { get; set; } } } diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Settings/ContentPickerFieldLuceneEditorSettingsDriver.cs b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Settings/ContentPickerFieldLuceneEditorSettingsDriver.cs index f0da853fcc0..40e43067f88 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Settings/ContentPickerFieldLuceneEditorSettingsDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Settings/ContentPickerFieldLuceneEditorSettingsDriver.cs @@ -1,8 +1,9 @@ -using System; using System.Linq; +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.ContentTypes.Editors; +using OrchardCore.DisplayManagement.Handlers; using OrchardCore.DisplayManagement.Views; namespace OrchardCore.Search.Lucene.Settings @@ -16,13 +17,13 @@ public ContentPickerFieldLuceneEditorSettingsDriver(LuceneIndexSettingsService l _luceneIndexSettingsService = luceneIndexSettingsService; } - public override IDisplayResult Edit(ContentPartFieldDefinition partFieldDefinition) + public override async Task EditAsync(ContentPartFieldDefinition partFieldDefinition, BuildEditorContext context) { - return Initialize("ContentPickerFieldLuceneEditorSettings_Edit", async model => - { - partFieldDefinition.PopulateSettings(model); - model.Indices = (await _luceneIndexSettingsService.GetSettingsAsync()).Select(x => x.IndexName).ToArray(); - }).Location("Editor"); + var model = partFieldDefinition.Settings.ToObject(); + model.Indices = (await _luceneIndexSettingsService.GetSettingsAsync()).Select(x => x.IndexName).ToArray(); + + return Copy("ContentPickerFieldLuceneEditorSettings_Edit", model) + .Location("Editor"); } public override async Task UpdateAsync(ContentPartFieldDefinition partFieldDefinition, UpdatePartFieldEditorContext context) @@ -36,7 +37,7 @@ public override async Task UpdateAsync(ContentPartFieldDefinitio context.Builder.WithSettings(model); } - return Edit(partFieldDefinition); + return await EditAsync(partFieldDefinition, context); } public override bool CanHandleModel(ContentPartFieldDefinition model) diff --git a/src/OrchardCore.Modules/OrchardCore.Settings/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Settings/Controllers/AdminController.cs index 002aa0d538d..1515023c57d 100644 --- a/src/OrchardCore.Modules/OrchardCore.Settings/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Settings/Controllers/AdminController.cs @@ -1,3 +1,4 @@ +using System.Text.Json.Nodes; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -79,10 +80,11 @@ public async Task IndexPost(string groupId) await _siteService.UpdateSiteSettingsAsync(site); string culture = null; - if (site.Properties.TryGetValue("LocalizationSettings", out var settings)) + if (site.Properties.TryGetPropertyValue("LocalizationSettings", out var settings)) { culture = settings.Value("DefaultCulture"); } + // We create a transient scope with the newly selected culture to create a notification that will use it instead of the previous culture using (culture != null ? CultureScope.Create(culture, ignoreSystemSettings: _cultureOptions.IgnoreSystemSettings) : null) { diff --git a/src/OrchardCore.Modules/OrchardCore.Settings/Recipes/SettingsStep.cs b/src/OrchardCore.Modules/OrchardCore.Settings/Recipes/SettingsStep.cs index 0d00b2bafc6..f87fdae1f0b 100644 --- a/src/OrchardCore.Modules/OrchardCore.Settings/Recipes/SettingsStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Settings/Recipes/SettingsStep.cs @@ -1,7 +1,7 @@ using System; +using System.Text.Json.Nodes; using System.Threading.Tasks; using Microsoft.AspNetCore.Routing; -using Newtonsoft.Json.Linq; using OrchardCore.Recipes.Models; using OrchardCore.Recipes.Services; @@ -29,9 +29,9 @@ public async Task ExecuteAsync(RecipeExecutionContext context) var model = context.Step; var site = await _siteService.LoadSiteSettingsAsync(); - foreach (JProperty property in model.Properties()) + foreach (var property in model) { - switch (property.Name) + switch (property.Key) { case "BaseUrl": site.BaseUrl = property.Value.ToString(); @@ -98,7 +98,7 @@ public async Task ExecuteAsync(RecipeExecutionContext context) break; default: - site.Properties[property.Name] = property.Value; + site.Properties[property.Key] = property.Value; break; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Shortcodes/Recipes/ShortcodeTemplateStep.cs b/src/OrchardCore.Modules/OrchardCore.Shortcodes/Recipes/ShortcodeTemplateStep.cs index 1491770126a..35540d8bd48 100644 --- a/src/OrchardCore.Modules/OrchardCore.Shortcodes/Recipes/ShortcodeTemplateStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Shortcodes/Recipes/ShortcodeTemplateStep.cs @@ -1,6 +1,6 @@ using System; +using System.Text.Json.Nodes; using System.Threading.Tasks; -using Newtonsoft.Json.Linq; using OrchardCore.Recipes.Models; using OrchardCore.Recipes.Services; using OrchardCore.Shortcodes.Models; @@ -27,11 +27,11 @@ public async Task ExecuteAsync(RecipeExecutionContext context) return; } - if (context.Step.Property("ShortcodeTemplates").Value is JObject templates) + if (context.Step.TryGetPropertyValue("ShortcodeTemplates", out var jsonNode) && jsonNode is JsonObject templates) { - foreach (var property in templates.Properties()) + foreach (var property in templates) { - var name = property.Name; + var name = property.Key; var value = property.Value.ToObject(); await _templatesManager.UpdateShortcodeTemplateAsync(name, value); diff --git a/src/OrchardCore.Modules/OrchardCore.Sitemaps/Recipes/SitemapsStep.cs b/src/OrchardCore.Modules/OrchardCore.Sitemaps/Recipes/SitemapsStep.cs index 86774f544fa..84fdc95a274 100644 --- a/src/OrchardCore.Modules/OrchardCore.Sitemaps/Recipes/SitemapsStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Sitemaps/Recipes/SitemapsStep.cs @@ -1,8 +1,7 @@ using System; using System.Linq; +using System.Text.Json.Nodes; using System.Threading.Tasks; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using OrchardCore.Recipes.Models; using OrchardCore.Recipes.Services; using OrchardCore.Sitemaps.Models; @@ -15,10 +14,10 @@ namespace OrchardCore.Sitemaps.Recipes /// public class SitemapsStep : IRecipeStepHandler { - private static readonly JsonSerializer _serializer = new() - { - TypeNameHandling = TypeNameHandling.Auto - }; + // private static readonly JsonSerializer _serializer = new() + // { + // TypeNameHandling = TypeNameHandling.Auto + // }; private readonly ISitemapManager _sitemapManager; @@ -36,16 +35,16 @@ public async Task ExecuteAsync(RecipeExecutionContext context) var model = context.Step.ToObject(); - foreach (var token in model.Data.Cast()) + foreach (var token in model.Data.Cast()) { - var sitemap = token.ToObject(_serializer); + var sitemap = token.ToObject(/*_serializer*/); await _sitemapManager.UpdateSitemapAsync(sitemap); } } public class SitemapStepModel { - public JArray Data { get; set; } + public JsonArray Data { get; set; } } } } diff --git a/src/OrchardCore.Modules/OrchardCore.Spatial/Drivers/GeoPointFieldSettingsDriver.cs b/src/OrchardCore.Modules/OrchardCore.Spatial/Drivers/GeoPointFieldSettingsDriver.cs index 49f813f1d2b..b77609cc471 100644 --- a/src/OrchardCore.Modules/OrchardCore.Spatial/Drivers/GeoPointFieldSettingsDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Spatial/Drivers/GeoPointFieldSettingsDriver.cs @@ -1,3 +1,4 @@ +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.ContentTypes.Editors; @@ -11,7 +12,7 @@ public class GeoPointFieldSettingsDriver : ContentPartFieldDefinitionDisplayDriv { public override IDisplayResult Edit(ContentPartFieldDefinition partFieldDefinition) { - return Initialize("GeoPointFieldSettings_Edit", model => partFieldDefinition.PopulateSettings(model)) + return Copy("GeoPointFieldSettings_Edit", partFieldDefinition.Settings.ToObject()) .Location("Content"); } diff --git a/src/OrchardCore.Modules/OrchardCore.Spatial/Views/GeoPointField-Leaflet.Edit.cshtml b/src/OrchardCore.Modules/OrchardCore.Spatial/Views/GeoPointField-Leaflet.Edit.cshtml index 7b06ae5d819..76610d1b41f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Spatial/Views/GeoPointField-Leaflet.Edit.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Spatial/Views/GeoPointField-Leaflet.Edit.cshtml @@ -1,6 +1,7 @@ -@using OrchardCore.Spatial.ViewModels -@using OrchardCore.Spatial.Settings @using System.Globalization +@using System.Text.Json.Nodes +@using OrchardCore.Spatial.Settings +@using OrchardCore.Spatial.ViewModels @model EditGeoPointFieldViewModel @{ var settings = Model.PartFieldDefinition.Settings.ToObject(); diff --git a/src/OrchardCore.Modules/OrchardCore.Spatial/Views/GeoPointField.Edit.cshtml b/src/OrchardCore.Modules/OrchardCore.Spatial/Views/GeoPointField.Edit.cshtml index 0ff4a20a116..f6f08cc81a9 100644 --- a/src/OrchardCore.Modules/OrchardCore.Spatial/Views/GeoPointField.Edit.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Spatial/Views/GeoPointField.Edit.cshtml @@ -1,7 +1,8 @@ -@using OrchardCore.Spatial.ViewModels -@using OrchardCore.Spatial.Settings -@using OrchardCore.Mvc.Utilities +@using System.Text.Json.Nodes @using OrchardCore +@using OrchardCore.Mvc.Utilities +@using OrchardCore.Spatial.Settings +@using OrchardCore.Spatial.ViewModels @model EditGeoPointFieldViewModel @{ var settings = Model.PartFieldDefinition.Settings.ToObject(); diff --git a/src/OrchardCore.Modules/OrchardCore.Taxonomies/Settings/TaxonomyFieldSettingsDriver.cs b/src/OrchardCore.Modules/OrchardCore.Taxonomies/Settings/TaxonomyFieldSettingsDriver.cs index adceb7b6935..090b5e45a1a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Taxonomies/Settings/TaxonomyFieldSettingsDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Taxonomies/Settings/TaxonomyFieldSettingsDriver.cs @@ -1,3 +1,4 @@ +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.ContentTypes.Editors; @@ -10,7 +11,7 @@ public class TaxonomyFieldSettingsDriver : ContentPartFieldDefinitionDisplayDriv { public override IDisplayResult Edit(ContentPartFieldDefinition partFieldDefinition) { - return Initialize("TaxonomyFieldSettings_Edit", model => partFieldDefinition.PopulateSettings(model)) + return Copy("TaxonomyFieldSettings_Edit", partFieldDefinition.Settings.ToObject()) .Location("Content"); } diff --git a/src/OrchardCore.Modules/OrchardCore.Taxonomies/Settings/TaxonomyFieldTagsEditorSettingsDriver.cs b/src/OrchardCore.Modules/OrchardCore.Taxonomies/Settings/TaxonomyFieldTagsEditorSettingsDriver.cs index bc0cf6298eb..7e0f06dbbf7 100644 --- a/src/OrchardCore.Modules/OrchardCore.Taxonomies/Settings/TaxonomyFieldTagsEditorSettingsDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Taxonomies/Settings/TaxonomyFieldTagsEditorSettingsDriver.cs @@ -1,3 +1,4 @@ +using System.Text.Json.Nodes; using System.Threading.Tasks; using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.ContentTypes.Editors; @@ -10,8 +11,8 @@ public class TaxonomyFieldTagsEditorSettingsDriver : ContentPartFieldDefinitionD { public override IDisplayResult Edit(ContentPartFieldDefinition partFieldDefinition) { - return Initialize("TaxonomyFieldTagsEditorSettings_Edit", model => partFieldDefinition.PopulateSettings(model)) - .Location("Editor"); + return Copy("TaxonomyFieldTagsEditorSettings_Edit", partFieldDefinition.Settings.ToObject()) + .Location("Content"); } public override async Task UpdateAsync(ContentPartFieldDefinition partFieldDefinition, UpdatePartFieldEditorContext context) diff --git a/src/OrchardCore.Modules/OrchardCore.Templates/Recipes/AdminTemplateStep.cs b/src/OrchardCore.Modules/OrchardCore.Templates/Recipes/AdminTemplateStep.cs index 492969f3119..21709373b7e 100644 --- a/src/OrchardCore.Modules/OrchardCore.Templates/Recipes/AdminTemplateStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Templates/Recipes/AdminTemplateStep.cs @@ -1,6 +1,6 @@ using System; +using System.Text.Json.Nodes; using System.Threading.Tasks; -using Newtonsoft.Json.Linq; using OrchardCore.Recipes.Models; using OrchardCore.Recipes.Services; using OrchardCore.Templates.Models; @@ -27,11 +27,11 @@ public async Task ExecuteAsync(RecipeExecutionContext context) return; } - if (context.Step.Property("AdminTemplates").Value is JObject templates) + if (context.Step.TryGetPropertyValue("AdminTemplates", out var jsonNode) && jsonNode is JsonObject templates) { - foreach (var property in templates.Properties()) + foreach (var property in templates) { - var name = property.Name; + var name = property.Key; var value = property.Value.ToObject