ComBoost principal wrapper.
Inheritance: IPrincipal
コード例 #1
0
        /// <summary>
        /// Get role entity from principal.
        /// </summary>
        /// <typeparam name="TUser">Type of user.</typeparam>
        /// <param name="principal">Principal.</param>
        /// <returns></returns>
        public static TUser GetUser <TUser>(this IPrincipal principal)
            where TUser : class, IRoleEntity
        {
            ComBoostPrincipal cp = principal as ComBoostPrincipal;

            return(GetUser <TUser>(cp));
        }
コード例 #2
0
        /// <summary>
        /// Determines whether the current principal belongs to the specified role.
        /// </summary>
        /// <param name="principal">Comboost principal.</param>
        /// <param name="role">Role.</param>
        /// <returns></returns>
        public static bool IsInRole(this IPrincipal principal, object role)
        {
            ComBoostPrincipal item = principal as ComBoostPrincipal;

            if (item == null)
            {
                throw new NotSupportedException("Only support with comboost principal.");
            }
            return(item.IsInRole(role));
        }
コード例 #3
0
        /// <summary>
        /// Get role entity from principal.
        /// </summary>
        /// <typeparam name="TUser">Type of user.</typeparam>
        /// <param name="principal">Principal.</param>
        /// <returns></returns>
        public static TUser GetUser <TUser>(this ComBoostPrincipal principal)
            where TUser : class, IRoleEntity
        {
            if (principal == null)
            {
                return(null);
            }
            TUser roleEntity = principal.RoleEntity as TUser;

            return(roleEntity);
        }
コード例 #4
0
ファイル: ComBoostIdentity.cs プロジェクト: liny4cn/ComBoost
 internal ComBoostIdentity(ComBoostPrincipal principal)
 {
     _Principal = principal;
 }
コード例 #5
0
ファイル: ComBoostIdentity.cs プロジェクト: alexyjian/Core3.0
 internal ComBoostIdentity(ComBoostPrincipal principal)
 {
     _Principal = principal;
 }