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

22 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 ProjectPermissionDefinitionProvider(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(ProjectPermissions.GroupName, _localizer["Permission:ProjectManager"]);
var productManagement = productGroup.AddPermission(ProjectPermissions.Projects.Default, _localizer["Permission:ProjectManager.Projects"]);
productManagement.AddChild(ProjectPermissions.Projects.Create, _localizer["Permission:ProjectManager.Projects.Creeate"]);
productManagement.AddChild(ProjectPermissions.Projects.Edit, _localizer["Permission:ProjectManager.Projects.Edit"]);
productManagement.AddChild(ProjectPermissions.Projects.Delete, _localizer["Permission:ProjectManager.Projects.Delete"]);
}
}
}