CfqAddrInfo.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace Ips.Library.Entity
  7. {
  8. public class CfqAddrInfo
  9. {
  10. public string CfqAddr { get; set; } = "";
  11. public string Addr { get; set; } = "";
  12. public int Port { get; set; } = 0;
  13. public int ChNum { get; set; } = 0;
  14. public static CfqAddrInfo Parse(string cfqAddr)
  15. {
  16. CfqAddrInfo result = new CfqAddrInfo();
  17. if (string.IsNullOrWhiteSpace(cfqAddr))
  18. return result;
  19. result.CfqAddr = cfqAddr;
  20. var itemArr = cfqAddr.Split('-');
  21. if (itemArr.Length >= 2 && int.TryParse(itemArr[1], out int chNum))
  22. {
  23. result.ChNum = chNum;
  24. }
  25. var addrItems = itemArr[0].Split(':');
  26. if (addrItems.Length > 1 && int.TryParse(addrItems[1], out int port))
  27. {
  28. result.Port = port;
  29. }
  30. result.Addr = addrItems[0];
  31. return result;
  32. }
  33. }
  34. }