public static bool IsGranted (IPermission perm)
{
if (perm == null)
return true;
if (!SecurityEnabled)
return true;
// - Policy driven
// - Only check the caller (no stack walk required)
// - Not affected by overrides (like Assert, Deny and PermitOnly)
// - calls IsSubsetOf even for non CAS permissions
// (i.e. it does call Demand so any code there won't be executed)
#if NET_2_0
// with 2.0 identity permission are unrestrictable
return IsGranted (Assembly.GetCallingAssembly (), perm);
#else
if (perm is IUnrestrictedPermission)
return IsGranted (Assembly.GetCallingAssembly (), perm);
else
return IsGrantedRestricted (Assembly.GetCallingAssembly (), perm);
#endif
}