Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use default json serializer options in urlrewriting module #17320

Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System.Text.Json;
using System.Text.Json.Nodes;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Options;
using OrchardCore.Recipes.Models;
using OrchardCore.Recipes.Services;
using OrchardCore.UrlRewriting.Models;
Expand All @@ -13,25 +11,22 @@ namespace OrchardCore.UrlRewriting.Recipes;
/// </summary>
public sealed class UrlRewritingStep : NamedRecipeStepHandler
{
private readonly JsonSerializerOptions _jsonSerializerOptions;
private readonly IRewriteRulesManager _rewriteRulesManager;

internal readonly IStringLocalizer S;

public UrlRewritingStep(
IRewriteRulesManager rewriteRulesManager,
IOptions<JsonSerializerOptions> jsonSerializerOptions,
IStringLocalizer<UrlRewritingStep> stringLocalizer)
: base("UrlRewriting")
{
_rewriteRulesManager = rewriteRulesManager;
_jsonSerializerOptions = jsonSerializerOptions.Value;
S = stringLocalizer;
}

protected override async Task HandleAsync(RecipeExecutionContext context)
{
var model = context.Step.ToObject<UrlRewritingStepModel>(_jsonSerializerOptions);
var model = context.Step.ToObject<UrlRewritingStepModel>();
var tokens = model.Rules.Cast<JsonObject>() ?? [];

foreach (var token in tokens)
Expand Down