Example #1
0
        public override EndPoint Create(SocketAddress socketAddress)
        {
            // Validate SocketAddress
            if (socketAddress.Family != this.AddressFamily)
            {
                throw new ArgumentException(SR.Format(SR.net_InvalidAddressFamily, socketAddress.Family.ToString(), this.GetType().FullName, this.AddressFamily.ToString()), nameof(socketAddress));
            }
            if (socketAddress.Size < 8)
            {
                throw new ArgumentException(SR.Format(SR.net_InvalidSocketAddressSize, socketAddress.GetType().FullName, this.GetType().FullName), nameof(socketAddress));
            }

            return(socketAddress.GetIPEndPoint());
        }
 /// <summary>
 /// Creates an endpoint from a socket address.
 /// </summary>
 ///
 /// <returns>
 /// An <see cref="T:System.Net.EndPoint"/> instance using the specified socket address.
 /// </returns>
 /// <param name="socketAddress">The <see cref="T:System.Net.SocketAddress"/> to use for the endpoint. </param><exception cref="T:System.ArgumentException">The AddressFamily of <paramref name="socketAddress"/> is not equal to the AddressFamily of the current instance.-or- <paramref name="socketAddress"/>.Size &lt; 8. </exception><PermissionSet><IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence"/></PermissionSet>
 public override EndPoint Create(SocketAddress socketAddress)
 {
     if (socketAddress.Family != this.AddressFamily)
     {
         throw new ArgumentException(SR.GetString("net_InvalidAddressFamily", (object)((object)socketAddress.Family).ToString(), (object)this.GetType().FullName, (object)((object)this.AddressFamily).ToString()), "socketAddress");
     }
     else
     {
         if (socketAddress.Size >= 8)
         {
             return((EndPoint)socketAddress.GetIPEndPoint());
         }
         throw new ArgumentException(SR.GetString("net_InvalidSocketAddressSize", (object)socketAddress.GetType().FullName, (object)this.GetType().FullName), "socketAddress");
     }
 }
Example #3
0
        public override EndPoint Create(SocketAddress socketAddress)
        {
            // Validate SocketAddress
            if (socketAddress.Family != this.AddressFamily)
            {
                throw new ArgumentException(SR.Format(SR.net_InvalidAddressFamily, socketAddress.Family.ToString(), this.GetType().FullName, this.AddressFamily.ToString()), "socketAddress");
            }
            if (socketAddress.Size < 8)
            {
                throw new ArgumentException(SR.Format(SR.net_InvalidSocketAddressSize, socketAddress.GetType().FullName, this.GetType().FullName), "socketAddress");
            }

            return socketAddress.GetIPEndPoint();
        }
 /// <summary>
 /// Creates an endpoint from a socket address.
 /// </summary>
 /// 
 /// <returns>
 /// An <see cref="T:System.Net.EndPoint"/> instance using the specified socket address.
 /// </returns>
 /// <param name="socketAddress">The <see cref="T:System.Net.SocketAddress"/> to use for the endpoint. </param><exception cref="T:System.ArgumentException">The AddressFamily of <paramref name="socketAddress"/> is not equal to the AddressFamily of the current instance.-or- <paramref name="socketAddress"/>.Size &lt; 8. </exception><PermissionSet><IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence"/></PermissionSet>
 public override EndPoint Create(SocketAddress socketAddress)
 {
     if (socketAddress.Family != this.AddressFamily)
       {
     throw new ArgumentException(SR.GetString("net_InvalidAddressFamily", (object) ((object) socketAddress.Family).ToString(), (object) this.GetType().FullName, (object) ((object) this.AddressFamily).ToString()), "socketAddress");
       }
       else
       {
     if (socketAddress.Size >= 8)
       return (EndPoint) socketAddress.GetIPEndPoint();
     throw new ArgumentException(SR.GetString("net_InvalidSocketAddressSize", (object) socketAddress.GetType().FullName, (object) this.GetType().FullName), "socketAddress");
       }
 }