コード例 #1
0
        public PermissionItem([NotNull] string name, string parent = null, PermissionAuthorizeScope scope = PermissionAuthorizeScope.Common)
        {
            Check.NotNull(name, nameof(name));

            this.Name   = name;
            this.Scope  = scope;
            this.Parent = parent;

            this.Sort = _sort++;

            this.HashCode = this.Name.GetHashCode() + this.Scope.GetHashCode();
        }
コード例 #2
0
ファイル: PermissionManager.cs プロジェクト: rivenfx/ProjectQ
        /// <summary>
        /// Permission 转树形数据结构
        /// </summary>
        /// <param name="permission"></param>
        /// <param name="scope"></param>
        /// <param name="defaultParent"></param>
        /// <returns></returns>
        static List <PermissionItem> PermissionToTree(string permission, PermissionAuthorizeScope scope, string defaultParent = null)
        {
            var result          = new List <PermissionItem>();
            var permissionArray = PermissionToArray(permission).Reverse <string>().ToList();

            if (permissionArray.Count == 0)
            {
                return(result);
            }


            var maxCount    = permissionArray.Count;
            var index       = 0;
            var parentIndex = index + 1;

            while (true)
            {
                var newPermission = permissionArray[index];
                if (maxCount == parentIndex)
                {
                    result.Add(
                        new PermissionItem(newPermission, defaultParent, scope)
                        );
                    break;
                }

                result.Add(
                    new PermissionItem(newPermission, permissionArray[parentIndex], scope)
                    );

                index++;
                parentIndex = index + 1;
            }


            return(result);
        }
コード例 #3
0
ファイル: PermissionManager.cs プロジェクト: rivenfx/ProjectQ
 public PermissionInfo(string name, PermissionAuthorizeScope scope)
 {
     Name  = name;
     Scope = scope;
 }
コード例 #4
0
 /// <summary>
 /// Creates a new instance of <see cref="PermissionAuthorizeAttribute"/> class.
 /// </summary>
 /// <param name="permissions">A list of permissions to authorize</param>
 public PermissionAuthorizeAttribute(params string[] permissions)
 {
     this.Permissions = permissions;
     this.Scope       = PermissionAuthorizeScope.Common;
     this.Policy      = PermissionAuthorizationPolicyProvider.POLICY_NAME;
 }