/// <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); }
public override IPermission Union(IPermission target) { // LAMESPEC: according to spec we should throw an // exception when target is null. We'll follow the // behaviour of MS.Net instead of the spec, also // because it matches the Intersect behaviour. if (target == null) { return(null); } // throw new ArgumentNullException ("target"); SocketPermission perm = target as SocketPermission; if (perm == null) { throw new ArgumentException("Argument not of type SocketPermission"); } if (this.m_noRestriction || perm.m_noRestriction) { return(new SocketPermission(PermissionState.Unrestricted)); } SocketPermission copy = (SocketPermission)perm.Copy(); copy.m_acceptList.InsertRange(copy.m_acceptList.Count, this.m_acceptList); copy.m_connectList.InsertRange(copy.m_connectList.Count, this.m_connectList); return(copy); }
public override IPermission Intersect(IPermission target) { if (target == null) { return(null); } SocketPermission perm = target as SocketPermission; if (perm == null) { throw new ArgumentException("Argument not of type SocketPermission"); } if (m_noRestriction) { return(IntersectEmpty(perm) ? null : perm.Copy()); } if (perm.m_noRestriction) { return(IntersectEmpty(this) ? null : this.Copy()); } SocketPermission newperm = new SocketPermission(PermissionState.None); Intersect(this.m_connectList, perm.m_connectList, newperm.m_connectList); Intersect(this.m_acceptList, perm.m_acceptList, newperm.m_acceptList); return(IntersectEmpty(newperm) ? null : newperm); }
public override IPermission Union(IPermission target) { if (target == null) { return(this.Copy()); } SocketPermission permission = target as SocketPermission; if (permission == null) { throw new ArgumentException(SR.GetString("net_perm_target"), "target"); } if (this.m_noRestriction || permission.m_noRestriction) { return(new SocketPermission(true)); } SocketPermission permission2 = (SocketPermission)permission.Copy(); for (int i = 0; i < this.m_connectList.Count; i++) { permission2.AddPermission(NetworkAccess.Connect, (EndpointPermission)this.m_connectList[i]); } for (int j = 0; j < this.m_acceptList.Count; j++) { permission2.AddPermission(NetworkAccess.Accept, (EndpointPermission)this.m_acceptList[j]); } return(permission2); }
public override IPermission Intersect(IPermission target) { SocketPermission permission2; if (target == null) { return(null); } SocketPermission permission = target as SocketPermission; if (permission == null) { throw new ArgumentException(SR.GetString("net_perm_target"), "target"); } if (this.m_noRestriction) { permission2 = (SocketPermission)permission.Copy(); } else if (permission.m_noRestriction) { permission2 = (SocketPermission)this.Copy(); } else { permission2 = new SocketPermission(false); intersectLists(this.m_connectList, permission.m_connectList, permission2.m_connectList); intersectLists(this.m_acceptList, permission.m_acceptList, permission2.m_acceptList); } if ((!permission2.m_noRestriction && (permission2.m_connectList.Count == 0)) && (permission2.m_acceptList.Count == 0)) { return(null); } return(permission2); }
/// <devdoc> /// <para> /// Returns the logical intersection between two <see cref='System.Net.SocketPermission'/> instances. /// </para> /// </devdoc> 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); }