ServerProperties.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using InABox.Core;
  4. using PRSClasses;
  5. namespace PRSServer
  6. {
  7. public abstract class ServerProperties : BaseObject
  8. {
  9. [TextBoxEditor]
  10. [Caption("Service Account Username")]
  11. [EditorSequence("Advanced",999)]
  12. public string Username { get; set; }
  13. public ServerProperties()
  14. {
  15. Name = CoreUtils.Neatify(Type().ToString());
  16. }
  17. [TextBoxEditor]
  18. [EditorSequence(-1)]
  19. public string Name { get; set; }
  20. public abstract ServerType Type();
  21. public List<string> CommandLineOptions(params string[] extras)
  22. {
  23. var options = new List<string>();
  24. var props = DatabaseSchema.Properties(GetType())
  25. .OrderBy(x => x.PropertySequence());
  26. foreach (var prop in props)
  27. options.Add(
  28. string.Format(
  29. "/{0}={1}{2}{1}",
  30. prop.Name,
  31. prop.PropertyType == typeof(string) ? "\"" : "",
  32. prop.Getter()(this)
  33. )
  34. );
  35. foreach (var extra in extras)
  36. options.Add(extra);
  37. return options;
  38. }
  39. }
  40. }