mirror of
https://github.com/bitwarden/server.git
synced 2025-01-07 19:37:51 +01:00
Make policyDefinitions dict immutable
This commit is contained in:
parent
8ffadc09e5
commit
9d75bcbc86
@ -1,5 +1,6 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
|
|
||||||
|
using System.Collections.Immutable;
|
||||||
using Bit.Core.AdminConsole.Entities;
|
using Bit.Core.AdminConsole.Entities;
|
||||||
using Bit.Core.AdminConsole.Enums;
|
using Bit.Core.AdminConsole.Enums;
|
||||||
using Bit.Core.AdminConsole.Models.Data.Organizations.Policies;
|
using Bit.Core.AdminConsole.Models.Data.Organizations.Policies;
|
||||||
@ -20,7 +21,7 @@ public class PolicyServicevNext : IPolicyServicevNext
|
|||||||
private readonly IApplicationCacheService _applicationCacheService;
|
private readonly IApplicationCacheService _applicationCacheService;
|
||||||
private readonly IEventService _eventService;
|
private readonly IEventService _eventService;
|
||||||
private readonly IPolicyRepository _policyRepository;
|
private readonly IPolicyRepository _policyRepository;
|
||||||
private readonly Dictionary<PolicyType, IPolicyDefinition> _policyDefinitions = new();
|
private readonly IReadOnlyDictionary<PolicyType, IPolicyDefinition> _policyDefinitions;
|
||||||
|
|
||||||
public PolicyServicevNext(
|
public PolicyServicevNext(
|
||||||
IApplicationCacheService applicationCacheService,
|
IApplicationCacheService applicationCacheService,
|
||||||
@ -32,10 +33,9 @@ public class PolicyServicevNext : IPolicyServicevNext
|
|||||||
_eventService = eventService;
|
_eventService = eventService;
|
||||||
_policyRepository = policyRepository;
|
_policyRepository = policyRepository;
|
||||||
|
|
||||||
foreach (var policyDefinition in policyDefinitions)
|
_policyDefinitions = ImmutableDictionary.CreateRange(
|
||||||
{
|
policyDefinitions.Select(def => KeyValuePair.Create(def.Type, def))
|
||||||
_policyDefinitions.Add(policyDefinition.Type, policyDefinition);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SaveAsync(Policy policy, IUserService userService, IOrganizationService organizationService,
|
public async Task SaveAsync(Policy policy, IUserService userService, IOrganizationService organizationService,
|
||||||
|
Loading…
Reference in New Issue
Block a user