ServerProperties.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. public string Username { get; set; }
  12. public ServerProperties()
  13. {
  14. Name = CoreUtils.Neatify(Type().ToString());
  15. }
  16. [TextBoxEditor]
  17. [EditorSequence(-1)]
  18. public string Name { get; set; }
  19. public abstract ServerType Type();
  20. public List<string> CommandLineOptions(params string[] extras)
  21. {
  22. var options = new List<string>();
  23. var props = CoreUtils.PropertyList(
  24. GetType(),
  25. x => x.GetEditor() != null
  26. && (x.DeclaringType == typeof(ServerProperties) || x.DeclaringType.IsSubclassOf(typeof(ServerProperties))
  27. )
  28. ).OrderBy(x => x.GetSequence());
  29. foreach (var prop in props)
  30. options.Add(
  31. string.Format(
  32. "/{0}={1}{2}{1}",
  33. prop.Name,
  34. prop.PropertyType == typeof(string) ? "\"" : "",
  35. prop.GetValue(this)
  36. )
  37. );
  38. foreach (var extra in extras)
  39. options.Add(extra);
  40. return options;
  41. }
  42. }
  43. }