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

21 lines
1.2 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 DevicePermissionDefinitionProvider(IStringLocalizerFactory factory) : IPermissionDefinitionProvider
{
private readonly IStringLocalizer _localizer = factory.Create("Permissions.MyPermissions", Assembly.GetExecutingAssembly().FullName ?? string.Empty);
public void Define(PermissionDefinitionContext context)
{
var deviceGroup = context.AddGroup(DevicePermissions.GroupName, _localizer["Permission:DeviceManager"]);
var deviceManagement = deviceGroup.AddPermission(DevicePermissions.Devices.Default, _localizer["Permission:DeviceManager.Devices"]);
deviceManagement.AddChild(DevicePermissions.Devices.Create, _localizer["Permission:DeviceManager.Devices.Creeate"]);
deviceManagement.AddChild(DevicePermissions.Devices.Edit, _localizer["Permission:DeviceManager.Devices.Edit"]);
deviceManagement.AddChild(DevicePermissions.Devices.Delete, _localizer["Permission:DeviceManager.Devices.Delete"]);
}
}
}