コード例 #1
0
        /// <summary>获取权限列表</summary>
        /// <param name="authorityKeys"></param>
        /// <returns></returns>
        public static IList <AuthorityInfo> GetAuthorities(string[] authorityKeys)
        {
            if (authorityKeys == null)
            {
                return(new List <AuthorityInfo>());
            }

            IList <AuthorityInfo> list = new List <AuthorityInfo>();

            foreach (string authorityKey in authorityKeys)
            {
                AuthorityInfo authority = AuthorityContext.Instance.AuthorityService[authorityKey];

                if (authority != null)
                {
                    list.Add(authority);
                }
            }

            return(list);
        }
コード例 #2
0
        /// <summary>获取多个权限列表的并集</summary>
        /// <param name="listA"></param>
        /// <param name="listB"></param>
        /// <returns></returns>
        public static IList <AuthorityInfo> GetUnionAuthorities(IList <AuthorityInfo> listA, params IList <AuthorityInfo>[] listB)
        {
            IList <AuthorityInfo> authorities = new List <AuthorityInfo>();

            AuthorityInfo authority = null;

            for (int i = 0; i < listA.Count; i++)
            {
                authority = listA[i];

                if (authority == null)
                {
                    continue;
                }

                authorities.Add(authority);
            }

            foreach (IList <AuthorityInfo> list in listB)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    authority = list[i];

                    if (authority == null)
                    {
                        continue;
                    }

                    if (!authorities.Contains(authority))
                    {
                        authorities.Add(authority);
                    }
                }
            }

            return(listA);
        }