46 lines
1.0 KiB
C#
46 lines
1.0 KiB
C#
using System;
|
|
using System.Net;
|
|
namespace ln.types.net
|
|
{
|
|
public class Endpoint4
|
|
{
|
|
public IPv4 IP { get; }
|
|
public int Port { get; }
|
|
|
|
private Endpoint4()
|
|
{
|
|
}
|
|
public Endpoint4(IPv4 ip,int port)
|
|
{
|
|
IP = ip;
|
|
Port = port;
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return IP.GetHashCode() ^ Port.GetHashCode();
|
|
}
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
if (obj is Endpoint4)
|
|
{
|
|
Endpoint4 you = obj as Endpoint4;
|
|
return IP.Equals(you.IP) && Port.Equals(you.Port);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
public static implicit operator IPEndPoint(Endpoint4 endpoint)
|
|
{
|
|
return new IPEndPoint(endpoint.IP, endpoint.Port);
|
|
}
|
|
public static implicit operator Endpoint4(IPEndPoint endpoint)
|
|
{
|
|
return new Endpoint4(endpoint.Address, endpoint.Port);
|
|
}
|
|
|
|
}
|
|
}
|