PageRenderTime 102ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/Terminals/Network/HelperFunctions.cs

#
C# | 51 lines | 47 code | 1 blank | 3 comment | 0 complexity | b5d56ba386d85f716659e480221cfc2c MD5 | raw file
Possible License(s): GPL-2.0
  1. using System;
  2. namespace Terminals.Network
  3. {
  4. /// <summary>
  5. /// Helper network function to simplify username, domain, hostname parsing
  6. /// </summary>
  7. internal static class HelperFunctions
  8. {
  9. internal static string UserDisplayName(string domain, string user)
  10. {
  11. return String.IsNullOrEmpty(domain) ? (user) : (domain + "\\" + user);
  12. }
  13. internal static string GetErrorMessage(int code)
  14. {
  15. //error messages from: http://msdn2.microsoft.com/en-us/aa382170.aspx
  16. switch (code)
  17. {
  18. case 260: return "DNS name lookup failure";
  19. case 262: return "Out of memory";
  20. case 264: return "Connection timed out";
  21. case 516: return "WinSock socket connect failure";
  22. case 518: return "Out of memory";
  23. case 520: return "Host not found error";
  24. case 772: return "WinSock send call failure";
  25. case 774: return "Out of memory";
  26. case 776: return "Invalid IP address specified";
  27. case 1028: return "WinSock recv call failure";
  28. case 1030: return "Invalid security data";
  29. case 1032: return "Internal error";
  30. case 1286: return "Invalid encryption method specified";
  31. case 1288: return "DNS lookup failed";
  32. case 1540: return "GetHostByName call failed";
  33. case 1542: return "Invalid server security data";
  34. case 1544: return "Internal timer error";
  35. case 1796: return "Time-out occurred";
  36. case 1798: return "Failed to unpack server certificate";
  37. case 2052: return "Bad IP address specified";
  38. case 2056: return "Internal security error";
  39. case 2308: return "Socket closed";
  40. case 2310: return "Internal security error";
  41. case 2312: return "Licensing time-out";
  42. case 2566: return "Internal security error";
  43. case 2822: return "Encryption error";
  44. case 3078: return "Decryption error";
  45. }
  46. return null;
  47. }
  48. }
  49. }