Innovenergy_trunk/csharp/Lib/Utils/Net/Ip4Address.cs

28 lines
881 B
C#
Raw Normal View History

namespace InnovEnergy.Lib.Utils.Net;
public class Ip4Address
{
2023-07-03 15:29:12 +00:00
public required String Host { get; init; }
public required UInt16 Port { get; init; }
public override String ToString() => $"{Host}:{Port}";
protected Boolean Equals(Ip4Address other)
{
return Host == other.Host
&& Port == other.Port;
}
public override Boolean Equals(Object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return Equals((Ip4Address)obj);
}
public static Boolean operator ==(Ip4Address? left, Ip4Address? right) => Equals(left, right);
public static Boolean operator !=(Ip4Address? left, Ip4Address? right) => !Equals(left, right);
public override Int32 GetHashCode() => ToString().GetHashCode();
}