Skip to content

Commit

Permalink
Remove unnecessary FrozenDictionary (#15623)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienros authored Mar 29, 2024
1 parent 42a2e0a commit 0fb5ce2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ namespace OrchardCore.Placements.Models
{
public class PlacementsDocument : Document
{
public Dictionary<string, PlacementNode[]> Placements { get; set; } = new Dictionary<string, PlacementNode[]>(StringComparer.OrdinalIgnoreCase);
public Dictionary<string, PlacementNode[]> Placements { get; } = new Dictionary<string, PlacementNode[]>(StringComparer.OrdinalIgnoreCase);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public async Task<IPlacementInfoResolver> BuildPlacementInfoResolverAsync(IBuild

public class PlacementInfoResolver : IPlacementInfoResolver
{
private readonly IReadOnlyDictionary<string, IEnumerable<PlacementNode>> _placements;
private readonly IReadOnlyDictionary<string, PlacementNode[]> _placements;
private readonly IEnumerable<IPlacementNodeFilterProvider> _placementNodeFilterProviders;

public PlacementInfoResolver(
IReadOnlyDictionary<string, IEnumerable<PlacementNode>> placements,
IReadOnlyDictionary<string, PlacementNode[]> placements,
IEnumerable<IPlacementNodeFilterProvider> placementNodeFilterProviders)
{
_placements = placements;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using OrchardCore.DisplayManagement.Descriptors.ShapePlacementStrategy;

namespace OrchardCore.Placements.Services
{
public class PlacementsManager
public sealed class PlacementsManager
{
private readonly IPlacementStore _placementStore;

public PlacementsManager(IPlacementStore placementStore)
=> _placementStore = placementStore;
{
_placementStore = placementStore;
}

public async Task<IReadOnlyDictionary<string, IEnumerable<PlacementNode>>> ListShapePlacementsAsync()
public async Task<IReadOnlyDictionary<string, PlacementNode[]>> ListShapePlacementsAsync()
{
var document = await _placementStore.GetPlacementsAsync();

return document.Placements.ToFrozenDictionary(kvp => kvp.Key, kvp => kvp.Value.AsEnumerable());
return document.Placements;
}

public async Task<IEnumerable<PlacementNode>> GetShapePlacementsAsync(string shapeType)
public async Task<PlacementNode[]> GetShapePlacementsAsync(string shapeType)
{
var document = await _placementStore.GetPlacementsAsync();

Expand Down

0 comments on commit 0fb5ce2

Please sign in to comment.