TestimoX

API Reference

Class

WindowsServiceCommandLine

Namespace ComputerX.Services
Assembly ComputerX
Modifiers sealed

Represents a Windows service executable path plus its command-line arguments.

Inheritance

  • Object
  • WindowsServiceCommandLine

Constructors

public WindowsServiceCommandLine(String executablePath, IEnumerable<String> arguments = null) #

Initializes a new instance of the WindowsServiceCommandLine class.

Parameters

executablePath System.String requiredposition: 0
Executable path used by the service.
arguments System.Collections.Generic.IEnumerable{System.String} = null optionalposition: 1
Arguments passed to the service process.

Methods

public String GetOptionValue(String option) #
Returns: String

Returns the value for the specified option when present.

Parameters

option System.String requiredposition: 0
Option name, for example --config.

Returns

Option value or null when the option is not present.

public String GetResolvedOptionPath(String option) #
Returns: String

Resolves an option value as a filesystem path relative to the executable directory when needed.

Parameters

option System.String requiredposition: 0
Option name, for example --config.

Returns

Resolved option path or null when the option is not present.

public Boolean HasOption(String option) #
Returns: Boolean

Returns whether the command line contains the specified option.

Parameters

option System.String requiredposition: 0
Option name, for example --config.

Returns

true when the option is present; otherwise false.

public static WindowsServiceCommandLine Parse(String commandLine) #
Returns: WindowsServiceCommandLine

Parses an SCM binary path into a strongly typed command line.

Parameters

commandLine System.String requiredposition: 0
Raw SCM binary path.

Returns

Parsed command line.

public static WindowsServiceCommandLine ParsePersistedValue(String persistedValue) #
Returns: WindowsServiceCommandLine

Parses a persisted service command-line value into a strongly typed command line.

Parameters

persistedValue System.String requiredposition: 0
Persisted SCM binary path or a registry-export style value containing ImagePath.

Returns

Parsed command line.

public String ResolvePath(String path) #
Returns: String

Resolves a path relative to the executable directory after expanding environment variables.

Parameters

path System.String requiredposition: 0
Path to resolve.

Returns

Resolved path.

public String ToImagePath() #
Returns: String

Converts the command line back into the SCM binary path format. Options are normalized to quoted split arguments as needed for SCM-safe round-tripping.

Returns

Serialized SCM binary path.

public override String ToString() #
Returns: String

Converts the command line back into the SCM binary path format.

Returns

Serialized SCM binary path.

public static Boolean TryParse(String commandLine, out WindowsServiceCommandLine parsed) #
Returns: Boolean

Parses an SCM binary path into a strongly typed command line.

Parameters

commandLine System.String requiredposition: 0
Raw SCM binary path.
parsed ComputerX.Services.WindowsServiceCommandLine@ requiredposition: 1
Parsed command line.

Returns

true when parsing succeeds; otherwise false.

public static Boolean TryParsePersistedValue(String persistedValue, out WindowsServiceCommandLine parsed) #
Returns: Boolean

Parses a persisted service command-line value into a strongly typed command line.

Parameters

persistedValue System.String requiredposition: 0
Persisted SCM binary path or a registry-export style value containing ImagePath.
parsed ComputerX.Services.WindowsServiceCommandLine@ requiredposition: 1
Parsed command line.

Returns

true when parsing succeeds; otherwise false.

public WindowsServiceCommandLine WithExecutablePath(String executablePath) #
Returns: WindowsServiceCommandLine

Creates a copy of the command line with a different executable path.

Parameters

executablePath System.String requiredposition: 0
New executable path.

Returns

Updated command line.

public WindowsServiceCommandLine WithOptionValue(String option, String value) #
Returns: WindowsServiceCommandLine

Creates a copy of the command line with the specified option value replaced or appended.

Parameters

option System.String requiredposition: 0
Option name, for example --config.
value System.String requiredposition: 1
Option value.

Returns

Updated command line.

public WindowsServiceCommandLine WithOptionValues(IEnumerable<KeyValuePair<String, String>> optionValues) #
Returns: WindowsServiceCommandLine

Creates a copy of the command line with multiple option values replaced or appended.

Parameters

optionValues System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}} requiredposition: 0
Option values keyed by canonical option name.

Returns

Updated command line.

Properties

public String ExecutablePath { get; } #

Gets the executable path used by the service.

public String ExpandedExecutablePath { get; } #

Gets the executable path after expanding environment variables.

public String ExecutableDirectory { get; } #

Gets the directory that contains the service executable, when it can be determined.

public IReadOnlyList<String> Arguments { get; } #

Gets the command-line arguments passed after the executable path.