Class OSUtils
Provides helper methods related to operating system functionality across multiple platforms.
public static class OSUtils
- Inheritance
-
objectOSUtils
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
valuestringThe string containing variables to be expanded.
variablesIDictionary<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
valuestringThe string containing variables to be expanded.
variablesStringDictionaryThe 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
reasonstringWhy 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
reasonstringWhy the system should not enter idle mode.
Returns
- IDisposable
Call Dispose() to restore the original state.