using System; using System.Collections.Generic; namespace VCommon.VApplication.Authorization { public class PermissionNode { private readonly PermissionTree _tree; private readonly List _children = new List(); /// /// 权限代码, 产品内唯一 /// public string Code { get; } /// /// 面向用户的显示名称 /// public string Name { get; } /// /// 面向用户的描述 /// public string Description { get; } /// /// 面向运营商的显示名称 /// public string NameForOperator { get; } /// /// 面向运营商的描述 /// public string DescriptionForOperator { get; } public MultiTenancySides TenancySide { get; } public IReadOnlyList Children => _children; internal PermissionNode(PermissionTree tree, string code, string name, string description, string nameForOperator, string descriptionForOperator, MultiTenancySides side = MultiTenancySides.Both) { _tree = tree; Code = code; Name = name; Description = description; NameForOperator = nameForOperator; DescriptionForOperator = descriptionForOperator; TenancySide = side; } public PermissionNode CreateChildNode(string code, string name, string description = null, string nameForOperator = null, string descriptionForOperator = null, MultiTenancySides side = MultiTenancySides.Both) { if (_tree.CodeHashSet.Contains(code)) throw new ArgumentException($"重复的权限代码:{code},名称:{name}"); var node = new PermissionNode(_tree, code, name, description, nameForOperator, descriptionForOperator, side); _children.Add(node); _tree._allNode.Add(node); _tree.CodeHashSet.Add(code); return node; } } }