zeroframework/Services/DeviceCenter/ZeroFramework.DeviceCenter.Application/PermissionProviders/ProjectPermissionDefinitionProvider.cs
2023-12-05 17:22:48 +08:00

22 lines
1.2 KiB
C#

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"]);
}
}
}