public IsSubsetOf ( IPermission target ) : bool | ||
target | IPermission | |
return | bool |
public bool IsSubsetOf(IPermission target)
{
if (target == null)
{
return IsEmpty();
}
else if (!VerifyType(target))
{
throw new ArgumentException(SR.Argument_WrongType, GetType().FullName);
}
PrincipalPermission operand = (PrincipalPermission)target;
if (operand.IsUnrestricted())
{
return true;
}
else if (IsUnrestricted())
{
return false;
}
foreach (IDRole idRole in _idArray)
{
bool foundMatch = false;
foreach (IDRole operandIdRole in operand._idArray)
{
if ((operandIdRole.Authenticated == idRole.Authenticated) &&
(operandIdRole.ID == null || (idRole.ID != null && idRole.ID.Equals(operandIdRole.ID))) &&
(operandIdRole.Role == null || (idRole.Role != null && idRole.Role.Equals(operandIdRole.Role))))
{
foundMatch = true;
break;
}
}
if (!foundMatch)
return false;
}
return true;
}
PrincipalPermission::IsSubsetOf ( System target ) : bool |
public void IsSubsetOfBadPermission () { PrincipalPermission p1 = new PrincipalPermission ("user", null); EnvironmentPermission ep2 = new EnvironmentPermission (PermissionState.Unrestricted); Assert ("IsSubsetOf(EnvironmentPermission)", p1.IsSubsetOf (ep2)); }