System.Web.Security.ComBoostPrincipal.IsInRole C# (CSharp) Method

IsInRole() public method

Determines whether the current principal belongs to the specified role.
public IsInRole ( object role ) : bool
role object Role.
return bool
        public bool IsInRole(object role)
        {
            if (!OriginPrincipal.Identity.IsAuthenticated)
                return false;
            if (Resolver == null)
                throw new NotSupportedException("Resolver is null.");
            if (RoleEntity == null)
                return false;
            return RoleEntity.IsInRole(role);
        }

Same methods

ComBoostPrincipal::IsInRole ( string role ) : bool

Usage Example

        /// <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));
        }