/// <summary> /// Returns true if the policy is of the expected type. Takes care of checking for lazy policies. /// </summary> /// <param name="securityPolicy">The policy</param> /// <returns>A boolean</returns> internal static bool IsPolicyOf <TSecurityPolicy>(this ISecurityPolicy securityPolicy) where TSecurityPolicy : class, ISecurityPolicy { var isMatch = securityPolicy is TSecurityPolicy; if (!isMatch) { isMatch = securityPolicy.GetPolicyType() == typeof(TSecurityPolicy); } return(isMatch); }
/// <summary> /// Returns true if the policy implements ICacheKeyProvider /// </summary> /// <param name="securityPolicy">The policy</param> /// <returns>A boolean</returns> internal static bool IsCacheKeyProvider(this ISecurityPolicy securityPolicy) { return(typeof(ICacheKeyProvider).IsAssignableFrom(securityPolicy.GetPolicyType())); }