/// <summary>
        ///
        /// </summary>
        /// <param name="permissionDesp"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public static bool UserHasPermissions(this PermissionDescriptionAttribute permissionDesp, IUser user)
        {
            bool result = false;

            if (permissionDesp != null && user != null)
            {
                ApplicationAndPermissionObjectsCollection pods = PermissionDescriptionParser.ParseApplicationAndPermissionObjects(permissionDesp.Description);

                foreach (ApplicationAndPermissionObjects pod in pods)
                {
                    foreach (string permissionCodeName in pod.PermissionObjectCodeNames)
                    {
                        if (user.Permissions[pod.ApplicationCodeName, permissionCodeName] != null)
                        {
                            result = true;
                            break;
                        }
                    }

                    if (result)
                    {
                        break;
                    }
                }
            }

            return(result);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 分析出一个结构化数据
 /// </summary>
 /// <returns></returns>
 public ApplicationAndPermissionObjectsCollection Parse()
 {
     return(PermissionDescriptionParser.ParseApplicationAndPermissionObjects(this.Description));
 }