Options.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System;
  2. using Base;
  3. using MongoDB.Bson.Serialization.Attributes;
  4. #if SERVER
  5. using CommandLine;
  6. #endif
  7. namespace Model
  8. {
  9. public class Options: ICloneable
  10. {
  11. #if SERVER
  12. [Option("appId", Required = true)]
  13. #endif
  14. public int AppId { get; set; }
  15. #if SERVER
  16. [Option("appType", Required = true)]
  17. #endif
  18. public AppType AppType { get; set; }
  19. #if SERVER
  20. [Option("config", Required = false, DefaultValue = "Start.txt")]
  21. #endif
  22. public string Config { get; set; }
  23. public object Clone()
  24. {
  25. return MongoHelper.FromBson<Options>(MongoHelper.ToBson(this));
  26. }
  27. }
  28. [BsonIgnoreExtraElements]
  29. public class InnerConfig: Component
  30. {
  31. public string Host { get; set; }
  32. public int Port { get; set; }
  33. [BsonIgnore]
  34. public string Address
  35. {
  36. get
  37. {
  38. return $"{this.Host}:{this.Port}";
  39. }
  40. }
  41. }
  42. [BsonIgnoreExtraElements]
  43. public class OuterConfig: Component
  44. {
  45. public string Host { get; set; }
  46. public int Port { get; set; }
  47. [BsonIgnore]
  48. public string Address
  49. {
  50. get
  51. {
  52. return $"{this.Host}:{this.Port}";
  53. }
  54. }
  55. }
  56. }