WGet.NET 4.4.1
A WinGet wrapper library for .Net.
Loading...
Searching...
No Matches
WGetNET.WinGet Class Reference

The WGetNET.WinGet class offers informations about the installed winget version. More...

Inheritance diagram for WGetNET.WinGet:
WGetNET.WinGetPackageManager WGetNET.WinGetSourceManager

Public Member Functions

 WinGet ()
 Initializes a new instance of the WGetNET.WinGet class.
 
string ExportSettings ()
 Exports the WinGet settings to a json string.
 
async Task< string > ExportSettingsAsync (CancellationToken cancellationToken=default)
 Asynchronous exports the WinGet settings to a json string.
 
void ExportSettingsToFile (string file)
 Exports the WinGet settings to a json and writes them to the given file.
 
async Task ExportSettingsToFileAsync (string file, CancellationToken cancellationToken=default)
 Asynchronous exports the WinGet settings to a json and writes them to the given file.
 
List< WinGetAdminSettingGetAdminSettings ()
 Gets all winget admin settings.
 
async Task< List< WinGetAdminSetting > > GetAdminSettingsAsync (CancellationToken cancellationToken=default)
 Asynchronously gets all winget admin settings.
 
bool EnableAdminSetting (string settingName)
 Enables the provided admin setting (Needs administrator rights).
 
bool EnableAdminSetting (WinGetAdminSetting setting)
 Enables the provided admin setting (Needs administrator rights).
 
async Task< bool > EnableAdminSettingAsync (string settingName, CancellationToken cancellationToken=default)
 Asynchronously enables the provided admin setting (Needs administrator rights).
 
async Task< bool > EnableAdminSettingAsync (WinGetAdminSetting setting, CancellationToken cancellationToken=default)
 Asynchronously enables the provided admin setting (Needs administrator rights).
 
bool DisableAdminSetting (string settingName)
 Disables the provided admin setting (Needs administrator rights).
 
bool DisableAdminSetting (WinGetAdminSetting setting)
 Disables the provided admin setting (Needs administrator rights).
 
async Task< bool > DisableAdminSettingAsync (string settingName, CancellationToken cancellationToken=default)
 Asynchronously disables the provided admin setting (Needs administrator rights).
 
async Task< bool > DisableAdminSettingAsync (WinGetAdminSetting setting, CancellationToken cancellationToken=default)
 Asynchronously disables the provided admin setting (Needs administrator rights).
 
WinGetInfo GetInfo ()
 Gets all WinGet related data provided by the WinGet info action.
 
async Task< WinGetInfoGetInfoAsync (CancellationToken cancellationToken=default)
 Asynchronous gets all WinGet related data provided by the WinGet info action.
 
WinGetResult ExecuteCustom (WinGetArguments args)
 Exectutes WinGet with the provided arguments.
 
WinGetResult ExecuteCustom (string args)
 Exectutes WinGet with the provided arguments.
 
async Task< WinGetResultExecuteCustomAsync (WinGetArguments args, CancellationToken cancellationToken=default)
 Asynchronously exectutes WinGet with the provided arguments.
 
async Task< WinGetResultExecuteCustomAsync (string args, CancellationToken cancellationToken=default)
 Asynchronously exectutes WinGet with the provided arguments.
 

Properties

bool IsInstalled [get]
 Gets if winget is installed on the system.
 
bool IsPreview [get]
 Gets if the version of winget is a preview version.
 
string VersionString [get]
 Gets the version number of the winget installation.
 
Version Version [get]
 Gets the version number of the winget installation.
 

Detailed Description

The WGetNET.WinGet class offers informations about the installed winget version.

Definition at line 23 of file WinGet.cs.

Constructor & Destructor Documentation

◆ WinGet()

WGetNET.WinGet.WinGet ( )

Initializes a new instance of the WGetNET.WinGet class.

Definition at line 124 of file WinGet.cs.

Member Function Documentation

◆ DisableAdminSetting() [1/2]

bool WGetNET.WinGet.DisableAdminSetting ( string settingName)

Disables the provided admin setting (Needs administrator rights).

Parameters
settingNameName of the admin setting to disable.
Returns
true if the action was succesfull and false if it failed.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentNullExceptionA provided argument is null.
System.ArgumentExceptionA provided argument is empty.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 513 of file WinGet.cs.

◆ DisableAdminSetting() [2/2]

bool WGetNET.WinGet.DisableAdminSetting ( WinGetAdminSetting setting)

Disables the provided admin setting (Needs administrator rights).

Parameters
settingThe WGetNET.WinGetAdminSetting to disable.
Returns
true if the action was succesfull and false if it failed.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentNullExceptionA provided argument is null.
System.ArgumentExceptionA provided argument is empty.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 543 of file WinGet.cs.

◆ DisableAdminSettingAsync() [1/2]

async Task< bool > WGetNET.WinGet.DisableAdminSettingAsync ( string settingName,
CancellationToken cancellationToken = default )

Asynchronously disables the provided admin setting (Needs administrator rights).

Parameters
settingNameName of the admin setting to disable.
cancellationTokenThe System.Threading.CancellationToken for the System.Threading.Tasks.Task.
Returns
A System.Threading.Tasks.Task, containing the result. The result is true if the action was succesfull and false if it failed.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentNullExceptionA provided argument is null.
System.ArgumentExceptionA provided argument is empty.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 575 of file WinGet.cs.

◆ DisableAdminSettingAsync() [2/2]

async Task< bool > WGetNET.WinGet.DisableAdminSettingAsync ( WinGetAdminSetting setting,
CancellationToken cancellationToken = default )

Asynchronously disables the provided admin setting (Needs administrator rights).

Parameters
settingThe WGetNET.WinGetAdminSetting to disable.
cancellationTokenThe System.Threading.CancellationToken for the System.Threading.Tasks.Task.
Returns
A System.Threading.Tasks.Task, containing the result. The result is true if the action was succesfull and false if it failed.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentNullExceptionA provided argument is null.
System.ArgumentExceptionA provided argument is empty.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 609 of file WinGet.cs.

◆ EnableAdminSetting() [1/2]

bool WGetNET.WinGet.EnableAdminSetting ( string settingName)

Enables the provided admin setting (Needs administrator rights).

Parameters
settingNameName of the admin setting to enable.
Returns
true if the action was succesfull and false if it failed.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentNullExceptionA provided argument is null.
System.ArgumentExceptionA provided argument is empty.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 389 of file WinGet.cs.

◆ EnableAdminSetting() [2/2]

bool WGetNET.WinGet.EnableAdminSetting ( WinGetAdminSetting setting)

Enables the provided admin setting (Needs administrator rights).

Parameters
settingThe WGetNET.WinGetAdminSetting to enable.
Returns
true if the action was succesfull and false if it failed.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentNullExceptionA provided argument is null.
System.ArgumentExceptionA provided argument is empty.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 419 of file WinGet.cs.

◆ EnableAdminSettingAsync() [1/2]

async Task< bool > WGetNET.WinGet.EnableAdminSettingAsync ( string settingName,
CancellationToken cancellationToken = default )

Asynchronously enables the provided admin setting (Needs administrator rights).

Parameters
settingNameName of the admin setting to enable.
cancellationTokenThe System.Threading.CancellationToken for the System.Threading.Tasks.Task.
Returns
A System.Threading.Tasks.Task, containing the result. The result is true if the action was succesfull and false if it failed.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentNullExceptionA provided argument is null.
System.ArgumentExceptionA provided argument is empty.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 451 of file WinGet.cs.

◆ EnableAdminSettingAsync() [2/2]

async Task< bool > WGetNET.WinGet.EnableAdminSettingAsync ( WinGetAdminSetting setting,
CancellationToken cancellationToken = default )

Asynchronously enables the provided admin setting (Needs administrator rights).

Parameters
settingThe WGetNET.WinGetAdminSetting to enable.
cancellationTokenThe System.Threading.CancellationToken for the System.Threading.Tasks.Task.
Returns
A System.Threading.Tasks.Task, containing the result. The result is true if the action was succesfull and false if it failed.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentNullExceptionA provided argument is null.
System.ArgumentExceptionA provided argument is empty.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 485 of file WinGet.cs.

◆ ExecuteCustom() [1/2]

WinGetResult WGetNET.WinGet.ExecuteCustom ( string args)

Exectutes WinGet with the provided arguments.

Parameters
argsA System.String containing the arguments for the WinGet process.
Returns
A WGetNET.WinGetResult object.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentNullExceptionA provided argument is null.
System.ArgumentExceptionA provided argument is empty.

Definition at line 735 of file WinGet.cs.

◆ ExecuteCustom() [2/2]

WinGetResult WGetNET.WinGet.ExecuteCustom ( WinGetArguments args)

Exectutes WinGet with the provided arguments.

Parameters
argsA WGetNET.WinGetArguments object containing the arguments for the WinGet process.
Returns
A WGetNET.WinGetResult object.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentNullExceptionA provided argument is null.

Definition at line 706 of file WinGet.cs.

◆ ExecuteCustomAsync() [1/2]

async Task< WinGetResult > WGetNET.WinGet.ExecuteCustomAsync ( string args,
CancellationToken cancellationToken = default )

Asynchronously exectutes WinGet with the provided arguments.

Parameters
argsA System.String containing the arguments for the WinGet process.
cancellationTokenThe System.Threading.CancellationToken for the System.Threading.Tasks.Task.
Returns
A System.Threading.Tasks.Task containing the WGetNET.WinGetResult object.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentNullExceptionA provided argument is null.
System.ArgumentExceptionA provided argument is empty.

Definition at line 798 of file WinGet.cs.

◆ ExecuteCustomAsync() [2/2]

async Task< WinGetResult > WGetNET.WinGet.ExecuteCustomAsync ( WinGetArguments args,
CancellationToken cancellationToken = default )

Asynchronously exectutes WinGet with the provided arguments.

Parameters
argsA WGetNET.WinGetArguments object containing the arguments for the WinGet process.
cancellationTokenThe System.Threading.CancellationToken for the System.Threading.Tasks.Task.
Returns
A System.Threading.Tasks.Task containing the WGetNET.WinGetResult object.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentNullExceptionA provided argument is null.

Definition at line 766 of file WinGet.cs.

◆ ExportSettings()

string WGetNET.WinGet.ExportSettings ( )

Exports the WinGet settings to a json string.

Returns
A System.String containing the settings json.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.

Definition at line 149 of file WinGet.cs.

◆ ExportSettingsAsync()

async Task< string > WGetNET.WinGet.ExportSettingsAsync ( CancellationToken cancellationToken = default)

Asynchronous exports the WinGet settings to a json string.

Parameters
cancellationTokenThe System.Threading.CancellationToken for the System.Threading.Tasks.Task.
Returns
A System.Threading.Tasks.Task, containing the result. The result is a System.String containing the settings json.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.

Definition at line 169 of file WinGet.cs.

◆ ExportSettingsToFile()

void WGetNET.WinGet.ExportSettingsToFile ( string file)

Exports the WinGet settings to a json and writes them to the given file.

Parameters
fileThe file for the export.
Returns
true if the action was succesfull, and false if it failed.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentNullExceptionA provided argument is null.
System.ArgumentExceptionA provided argument is empty.-or-The path contains one or more invalid characters as defined by System.IO.Path.InvalidPathChars.
System.IO.DirectoryNotFoundExceptionThe directory root does not exist.
System.IO.PathTooLongExceptionThe specified path, file name, or both exceed the system-defined maximum length.
System.UnauthorizedAccessExceptionThe caller does not have the required permission.
System.IO.IOExceptionAn I/O error occurred while opening the file
System.NotSupportedExceptionPath is in an invalid format.
System.Security.SecurityExceptionThe caller does not have the required permission.

Definition at line 214 of file WinGet.cs.

◆ ExportSettingsToFileAsync()

async Task WGetNET.WinGet.ExportSettingsToFileAsync ( string file,
CancellationToken cancellationToken = default )

Asynchronous exports the WinGet settings to a json and writes them to the given file.

Parameters
fileThe file for the export.
cancellationTokenThe System.Threading.CancellationToken for the System.Threading.Tasks.Task.
Returns
The System.Threading.Tasks.Task for the action.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentNullExceptionA provided argument is null.
System.ArgumentExceptionA provided argument is empty.-or-The path contains one or more invalid characters as defined by System.IO.Path.InvalidPathChars.
System.IO.DirectoryNotFoundExceptionThe directory root does not exist.
System.IO.PathTooLongExceptionThe specified path, file name, or both exceed the system-defined maximum length.
System.UnauthorizedAccessExceptionThe caller does not have the required permission.
System.IO.IOExceptionAn I/O error occurred while opening the file
System.NotSupportedExceptionPath is in an invalid format.
System.Security.SecurityExceptionThe caller does not have the required permission.

Definition at line 265 of file WinGet.cs.

◆ GetAdminSettings()

List< WinGetAdminSetting > WGetNET.WinGet.GetAdminSettings ( )

Gets all winget admin settings.

Returns
A System.Collections.Generic.List<T> of WGetNET.WinGetAdminSetting object.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.

Definition at line 286 of file WinGet.cs.

◆ GetAdminSettingsAsync()

async Task< List< WinGetAdminSetting > > WGetNET.WinGet.GetAdminSettingsAsync ( CancellationToken cancellationToken = default)

Asynchronously gets all winget admin settings.

Parameters
cancellationTokenThe System.Threading.CancellationToken for the System.Threading.Tasks.Task.
Returns
A System.Threading.Tasks.Task, containing the result. The result is a System.Collections.Generic.List<T> of WGetNET.WinGetAdminSetting object.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.

Definition at line 329 of file WinGet.cs.

◆ GetInfo()

WinGetInfo WGetNET.WinGet.GetInfo ( )

Gets all WinGet related data provided by the WinGet info action.

Returns
A WGetNET.WinGetInfo object containing winget related information.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.

Definition at line 627 of file WinGet.cs.

◆ GetInfoAsync()

async Task< WinGetInfo > WGetNET.WinGet.GetInfoAsync ( CancellationToken cancellationToken = default)

Asynchronous gets all WinGet related data provided by the WinGet info action.

Parameters
cancellationTokenThe System.Threading.CancellationToken for the System.Threading.Tasks.Task.
Returns
A System.Threading.Tasks.Task, containing the result. The result is a WGetNET.WinGetInfo object containing winget related information.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.

Definition at line 661 of file WinGet.cs.

Property Documentation

◆ IsInstalled

bool WGetNET.WinGet.IsInstalled
get

Gets if winget is installed on the system.

Returns
true if winget is installed or false if not.

Definition at line 40 of file WinGet.cs.

◆ IsPreview

bool WGetNET.WinGet.IsPreview
get

Gets if the version of winget is a preview version.

Returns
true if the winget version is a preview version or false if not.

Definition at line 64 of file WinGet.cs.

◆ Version

Version WGetNET.WinGet.Version
get

Gets the version number of the winget installation.

Returns
A System.Version object.

Definition at line 106 of file WinGet.cs.

◆ VersionString

string WGetNET.WinGet.VersionString
get

Gets the version number of the winget installation.

Returns
A System.String with the version number.

Definition at line 85 of file WinGet.cs.