public static EndPoint Create(this EndPoint thisObj, Internals.SocketAddress socketAddress) { AddressFamily family = socketAddress.Family; if (family != thisObj.AddressFamily) { throw new ArgumentException(SR.Format(SR.net_InvalidAddressFamily, family.ToString(), thisObj.GetType().FullName, thisObj.AddressFamily.ToString()), nameof(socketAddress)); } if (family == AddressFamily.InterNetwork || family == AddressFamily.InterNetworkV6) { if (socketAddress.Size < 8) { throw new ArgumentException(SR.Format(SR.net_InvalidSocketAddressSize, socketAddress.GetType().FullName, thisObj.GetType().FullName), nameof(socketAddress)); } return(socketAddress.GetIPEndPoint()); } else if (family == AddressFamily.Unknown) { return(thisObj); } System.Net.SocketAddress address = GetNetSocketAddress(socketAddress); return(thisObj.Create(address)); }
public static EndPoint Create(this EndPoint thisObj, Internals.SocketAddress socketAddress) { if (socketAddress.Family != thisObj.AddressFamily) { throw new ArgumentException(SR.Format(SR.net_InvalidAddressFamily, socketAddress.Family.ToString(), thisObj.GetType().FullName, thisObj.AddressFamily.ToString()), "socketAddress"); } if (socketAddress.Size < 8) { throw new ArgumentException(SR.Format(SR.net_InvalidSocketAddressSize, socketAddress.GetType().FullName, thisObj.GetType().FullName), "socketAddress"); } return(socketAddress.GetIPEndPoint()); }