Connections.cs 793 B

12345678910111213141516171819202122232425262728293031
  1. namespace Universal.IO;
  2. public enum ConnectionType
  3. {
  4. None = 0,
  5. Serial,
  6. Tcp,
  7. Udp,
  8. Pipe
  9. }
  10. public class Connection(ConnectionType connectionType)
  11. {
  12. public ConnectionType ConnectionType { get; } = connectionType;
  13. }
  14. public class TcpConnection(IPEndPoint localEndPoint, IPEndPoint remoteEndPoint, TcpClient tcpClient) : Connection(ConnectionType.Tcp)
  15. {
  16. public IPEndPoint LocalEndPoint { get; } = localEndPoint;
  17. public IPEndPoint RemoteEndPoint { get; } = remoteEndPoint;
  18. public TcpClient TcpClient { get; } = tcpClient;
  19. }
  20. public class SerialConnection(string serialPortName, SerialPort serialPort) : Connection(ConnectionType.Serial)
  21. {
  22. public string SerialPortName { get; } = serialPortName;
  23. public SerialPort SerialPort { get; } = serialPort;
  24. }