/// <devdoc>
/// <para>Returns the logical union between two <see cref='System.Net.SocketPermission'/> instances.</para>
/// </devdoc>
public override IPermission Union(IPermission target)
{
// Pattern suggested by Security engine
if (target == null)
{
return(this.Copy());
}
SocketPermission other = target as SocketPermission;
if (other == null)
{
throw new ArgumentException(SR.GetString(SR.net_perm_target), "target");
}
if (m_noRestriction || other.m_noRestriction)
{
return(new SocketPermission(true));
}
SocketPermission result = (SocketPermission)other.Copy();
for (int i = 0; i < m_connectList.Count; i++)
{
result.AddPermission(NetworkAccess.Connect, (EndpointPermission)m_connectList[i]);
}
for (int i = 0; i < m_acceptList.Count; i++)
{
result.AddPermission(NetworkAccess.Accept, (EndpointPermission)m_acceptList[i]);
}
return(result);
}