Options.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System;
  2. using System.Text;
  3. using Base;
  4. #if SERVER
  5. using CommandLine;
  6. #endif
  7. namespace Model
  8. {
  9. public class Options: ICloneable
  10. {
  11. #if SERVER
  12. [Option("id", Required = true, HelpText = "Id.")]
  13. #endif
  14. public int Id { get; set; }
  15. #if SERVER
  16. [Option("IP", Required = false, HelpText = "进程运行的服务器ip.")]
  17. #endif
  18. public string IP { get; set; }
  19. #if SERVER
  20. [Option("appType", Required = true, HelpText = "AppType: realm gate")]
  21. #endif
  22. public string AppType { get; set; }
  23. #if SERVER
  24. [Option("protocol", Required = false, HelpText = "Protocol, tcp or udp.", DefaultValue = NetworkProtocol.UDP)]
  25. #endif
  26. public NetworkProtocol Protocol { get; set; }
  27. #if SERVER
  28. [Option("host", Required = true, HelpText = "Host.")]
  29. #endif
  30. public string Host { get; set; }
  31. #if SERVER
  32. [Option("port", Required = true, HelpText = "Port.")]
  33. #endif
  34. public int Port { get; set; }
  35. #if SERVER
  36. [Option("gateHost", Required = false, HelpText = "GateHost.")]
  37. #endif
  38. public string GateHost { get; set; }
  39. #if SERVER
  40. [Option("gatePort", Required = false, HelpText = "GatePort.")]
  41. #endif
  42. public int GatePort { get; set; }
  43. #if SERVER
  44. [Option('v', HelpText = "Print details during execution.")]
  45. #endif
  46. public bool Verbose { get; set; }
  47. #if SERVER
  48. [HelpOption]
  49. #endif
  50. public string GetUsage()
  51. {
  52. // this without using CommandLine.Text
  53. StringBuilder usage = new StringBuilder();
  54. usage.AppendLine("Quickstart Application 1.0");
  55. usage.AppendLine("Read user manual for usage instructions...");
  56. return usage.ToString();
  57. }
  58. public object Clone()
  59. {
  60. return MongoHelper.FromBson<Options>(MongoHelper.ToBson(this));
  61. }
  62. }
  63. }