confused screaming
This commit is contained in:
11
PVHelpers/INetEndPoint.cs
Normal file
11
PVHelpers/INetEndPoint.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Net;
|
||||
|
||||
namespace PVHelpers
|
||||
{
|
||||
public interface INetEndPoint
|
||||
{
|
||||
public IPEndPoint EndPoint { get; }
|
||||
public IPAddress Address { get; }
|
||||
public Int32 Port { get; }
|
||||
}
|
||||
}
|
||||
20
PVHelpers/NetEndPointFromHostname.cs
Normal file
20
PVHelpers/NetEndPointFromHostname.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Net;
|
||||
|
||||
namespace PVHelpers
|
||||
{
|
||||
public class NetEndPointFromHostname(String hostname, Int32 port) : INetEndPoint
|
||||
{
|
||||
public String Hostname { get; } = hostname;
|
||||
public IPEndPoint EndPoint => new(this.Address, this.Port);
|
||||
|
||||
public IPAddress Address
|
||||
{
|
||||
get
|
||||
{
|
||||
IPHostEntry entry = Dns.GetHostEntry(this.Hostname);
|
||||
return entry.AddressList[0];
|
||||
}
|
||||
}
|
||||
public Int32 Port { get; } = port;
|
||||
}
|
||||
}
|
||||
18
PVHelpers/NetEndPointFromIP.cs
Normal file
18
PVHelpers/NetEndPointFromIP.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Net;
|
||||
|
||||
namespace PVHelpers
|
||||
{
|
||||
public class NetEndPointFromIP : INetEndPoint
|
||||
{
|
||||
public IPEndPoint EndPoint { get; }
|
||||
public IPAddress Address => this.EndPoint.Address;
|
||||
public Int32 Port => this.EndPoint.Port;
|
||||
|
||||
public NetEndPointFromIP(IPEndPoint endpoint)
|
||||
{
|
||||
this.EndPoint = endpoint;
|
||||
}
|
||||
|
||||
public NetEndPointFromIP(IPAddress address, Int32 port) : this(new(address, port)) { }
|
||||
}
|
||||
}
|
||||
9
PVHelpers/PVHelpers.csproj
Normal file
9
PVHelpers/PVHelpers.csproj
Normal file
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user