public override IPermission Intersect(IPermission target) {
// Pattern suggested by Security engine
if (target == null) {
return null;
}
SocketPermission other = target as SocketPermission;
if(other == null) {
throw new ArgumentException(SR.GetString(SR.net_perm_target), "target");
}
SocketPermission result;
if (m_noRestriction) {
result = (SocketPermission)(other.Copy());
}
else if (other.m_noRestriction) {
result = (SocketPermission)(this.Copy());
}
else {
result = new SocketPermission(false);
intersectLists(m_connectList, other.m_connectList, result.m_connectList);
intersectLists(m_acceptList, other.m_acceptList, result.m_acceptList);
}
// return null if resulting permission is restricted and empty
if (!result.m_noRestriction &&
result.m_connectList.Count == 0 && result.m_acceptList.Count == 0) {
return null;
}
return result;
}