12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using System.Collections.Generic;
- using System.Linq;
- using InABox.Core;
- using PRSClasses;
- namespace PRSServer
- {
- public abstract class ServerProperties : BaseObject
- {
- [TextBoxEditor]
- [Caption("Service Account Username")]
- public string Username { get; set; }
- public ServerProperties()
- {
- Name = CoreUtils.Neatify(Type().ToString());
- }
- [TextBoxEditor]
- [EditorSequence(-1)]
- public string Name { get; set; }
- public abstract ServerType Type();
- public List<string> CommandLineOptions(params string[] extras)
- {
- var options = new List<string>();
- var props = CoreUtils.PropertyList(
- GetType(),
- x => x.GetEditor() != null
- && (x.DeclaringType == typeof(ServerProperties) || x.DeclaringType.IsSubclassOf(typeof(ServerProperties))
- )
- ).OrderBy(x => x.GetSequence());
- foreach (var prop in props)
- options.Add(
- string.Format(
- "/{0}={1}{2}{1}",
- prop.Name,
- prop.PropertyType == typeof(string) ? "\"" : "",
- prop.GetValue(this)
- )
- );
- foreach (var extra in extras)
- options.Add(extra);
- return options;
- }
- }
- }
|