internal static IPermission CheckPermissionSet (Assembly a, PermissionSet ps, bool noncas)
{
if (ps.IsEmpty ())
return null;
foreach (IPermission p in ps) {
// note: this may contains non CAS permissions
if ((!noncas) && (p is CodeAccessPermission)) {
#if NET_2_0
if (!IsGranted (a, p))
return p;
#else
if (p is IUnrestrictedPermission) {
if (!IsGranted (a, p))
return p;
} else {
if (!IsGrantedRestricted (a, p))
return p;
}
#endif
} else {
// but non-CAS will throw on failure...
try {
p.Demand ();
}
catch (SecurityException) {
// ... so we catch
return p;
}
}
}
return null;
}