/// <summary> /// Returns the requested entity only if the access is allowed or the provider is null /// </summary> /// <typeparam name="TReturn">The type of the entity to return</typeparam> /// <typeparam name="TProvider">The entity type being checked</typeparam> /// <param name="provider">The provider to use try and use for this check</param> /// <param name="entity">The entity to check permissions on</param> /// <returns>The entity, or null if access is explicitely denied</returns> public static TReturn TryFind <TReturn, TProvider>(this ISecurityProvider <TProvider> provider, TReturn entity) where TReturn : class, TProvider { if (provider.TryCheckAccess(entity)) { return(entity); } else { return(null); } }