Table of Contents

Class OSUtils

Namespace
NanoByte.Common.Native
Assembly
NanoByte.Common.dll

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 string

The string containing variables to be expanded.

variables IDictionary<string, string>

The list of variables available for expansion.

Returns

string

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 string

The string containing variables to be expanded.

variables StringDictionary

The list of variables available for expansion.

Returns

string

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 string

Why 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 string

Why the system should not enter idle mode.

Returns

IDisposable

Call Dispose() to restore the original state.