Options.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Text;
  3. using Base;
  4. using MongoDB.Bson.Serialization.Attributes;
  5. #if SERVER
  6. using CommandLine;
  7. #endif
  8. namespace Model
  9. {
  10. public class Options: ICloneable
  11. {
  12. #if SERVER
  13. [Option("appId", Required = true, HelpText = "Id.")]
  14. #endif
  15. public int AppId { get; set; }
  16. #if SERVER
  17. [Option("appType", Required = true, HelpText = "AppType: realm gate")]
  18. #endif
  19. public string AppType { get; set; }
  20. #if SERVER
  21. [HelpOption]
  22. #endif
  23. public string GetUsage()
  24. {
  25. // this without using CommandLine.Text
  26. StringBuilder usage = new StringBuilder();
  27. usage.AppendLine("Quickstart Application 1.0");
  28. usage.AppendLine("Read user manual for usage instructions...");
  29. return usage.ToString();
  30. }
  31. public object Clone()
  32. {
  33. return MongoHelper.FromBson<Options>(MongoHelper.ToBson(this));
  34. }
  35. }
  36. [BsonIgnoreExtraElements]
  37. public class InnerConfig: Component
  38. {
  39. public string Host { get; set; }
  40. public int Port { get; set; }
  41. [BsonIgnore]
  42. public string Address
  43. {
  44. get
  45. {
  46. return $"{this.Host}:{this.Port}";
  47. }
  48. }
  49. }
  50. [BsonIgnoreExtraElements]
  51. public class OuterConfig: Component
  52. {
  53. public string Host { get; set; }
  54. public int Port { get; set; }
  55. [BsonIgnore]
  56. public string Address
  57. {
  58. get
  59. {
  60. return $"{this.Host}:{this.Port}";
  61. }
  62. }
  63. }
  64. }