zeroframework/Services/DeviceCenter/ZeroFramework.DeviceCenter.Application/PermissionProviders/ResourceGroupPermissionDefinitionProvider.cs

22 lines
1.3 KiB
C#
Raw Normal View History

2023-12-05 09:22:48 +00:00
using Microsoft.Extensions.Localization;
using System.Reflection;
using ZeroFramework.DeviceCenter.Application.Services.Permissions;
namespace ZeroFramework.DeviceCenter.Application.PermissionProviders
{
public class ResourceGroupPermissionDefinitionProvider(IStringLocalizerFactory factory) : IPermissionDefinitionProvider
{
private readonly IStringLocalizer _localizer = factory.Create("Permissions.MyPermissions", Assembly.GetExecutingAssembly().FullName ?? string.Empty);
public void Define(PermissionDefinitionContext context)
{
var productGroup = context.AddGroup(ResourceGroupPermissions.GroupName, _localizer["Permission:ResourceGroupManager"]);
var productManagement = productGroup.AddPermission(ResourceGroupPermissions.ResourceGroups.Default, _localizer["Permission:ResourceGroupManager.ResourceGroups"]);
productManagement.AddChild(ResourceGroupPermissions.ResourceGroups.Create, _localizer["Permission:ResourceGroupManager.ResourceGroups.Creeate"]);
productManagement.AddChild(ResourceGroupPermissions.ResourceGroups.Edit, _localizer["Permission:ResourceGroupManager.ResourceGroups.Edit"]);
productManagement.AddChild(ResourceGroupPermissions.ResourceGroups.Delete, _localizer["Permission:ResourceGroupManager.ResourceGroups.Delete"]);
}
}
}