Class OSUtils
Provides helper methods related to operating system functionality across multiple platforms.
public static class OSUtils
- Inheritance
-
OSUtils
Methods
ExpandVariables(string, IDictionary<string, string?>)
Expands/substitutes any Unix-style environment variables in the string.
public static string ExpandVariables(string value, IDictionary<string, string?> variables)
Parameters
value
stringThe string containing variables to be expanded.
variables
IDictionary<string, string>The list of variables available for expansion.
Returns
Remarks
Supports default values for unset variables (\({VAR-default}</code>) and for unset or empty variables (<code>\){VAR:-default}
).
ExpandVariables(string, StringDictionary)
Expands/substitutes any Unix-style environment variables in the string.
public static string ExpandVariables(string value, StringDictionary variables)
Parameters
value
stringThe string containing variables to be expanded.
variables
StringDictionaryThe list of variables available for expansion.
Returns
Remarks
Supports default values for unset variables (\({VAR-default}</code>) and for unset or empty variables (<code>\){VAR:-default}
).
PreventDisplayOff(string)
Asks the operating system not to turn off the display.
[MustDisposeResource]
public static IDisposable? PreventDisplayOff(string reason)
Parameters
reason
stringWhy the display should not be turned off.
Returns
- IDisposable
Call Dispose() to restore the original state.
PreventIdle(string)
Asks the operating system not to enter idle mode. Useful to avoid standby or hibernation during a long-running task.
[MustDisposeResource]
public static IDisposable? PreventIdle(string reason)
Parameters
reason
stringWhy the system should not enter idle mode.
Returns
- IDisposable
Call Dispose() to restore the original state.