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

The WGetNET.WinGetSourceManager class offers methods to manage the sources used by winget. More...

Inheritance diagram for WGetNET.WinGetSourceManager:
WGetNET.WinGet

Public Member Functions

 WinGetSourceManager ()
 Initializes a new instance of the WGetNET.WinGetSourceManager class.
 
List< WinGetSourceGetInstalledSources ()
 Gets a list of all sources that are installed in winget.
 
List< WinGetSourceGetInstalledSources (string sourceName)
 Gets a list of installed sources that matches the provided name.
 
async Task< List< WinGetSource > > GetInstalledSourcesAsync (CancellationToken cancellationToken=default)
 Asynchronously gets a list of all sources that are installed in winget.
 
async Task< List< WinGetSource > > GetInstalledSourcesAsync (string sourceName, CancellationToken cancellationToken=default)
 Asynchronously gets a list of installed sources that matches the provided name.
 
bool AddSource (string name, string arg)
 Adds a new source to winget (Needs administrator rights).
 
bool AddSource (string name, string arg, string type)
 Adds a new source to winget (Needs administrator rights).
 
bool AddSource (WinGetSource source)
 Adds a new source to winget (Needs administrator rights).
 
bool AddSource (IEnumerable< WinGetSource > sources)
 Adds multiple new sources to winget (Needs administrator rights).
 
async Task< bool > AddSourceAsync (string name, string arg, CancellationToken cancellationToken=default)
 Asynchronously adds a new source to winget (Needs administrator rights).
 
async Task< bool > AddSourceAsync (string name, string arg, string type, CancellationToken cancellationToken=default)
 Asynchronously adds a new source to winget (Needs administrator rights).
 
async Task< bool > AddSourceAsync (WinGetSource source, CancellationToken cancellationToken=default)
 Asynchronously adds a new source to winget (Needs administrator rights).
 
async Task< bool > AddSourceAsync (IEnumerable< WinGetSource > sources, CancellationToken cancellationToken=default)
 Asynchronously adds multiple new sources to winget (Needs administrator rights).
 
bool UpdateSources ()
 Updates all sources that are installed in winget.
 
async Task< bool > UpdateSourcesAsync (CancellationToken cancellationToken=default)
 Asynchronously updates all sources that are installed in winget.
 
void ExportSourcesToFile (string file)
 Exports the winget sources in json format to a file.
 
void ExportSourcesToFile (string file, string sourceName)
 Exports the winget sources in json format to a file.
 
void ExportSourcesToFile (string file, WinGetSource source)
 Exports the winget sources in json format to a file.
 
async Task ExportSourcesToFileAsync (string file, CancellationToken cancellationToken=default)
 Asynchronously exports the winget sources in json format to a file.
 
async Task ExportSourcesToFileAsync (string file, string sourceName, CancellationToken cancellationToken=default)
 Asynchronously exports the winget sources in json format to a file.
 
async Task ExportSourcesToFileAsync (string file, WinGetSource source, CancellationToken cancellationToken=default)
 Asynchronously exports the winget sources in json format to a file.
 
bool ImportSourcesFromJson (string jsonString)
 Imports sources into winget from a json string.
 
async Task< bool > ImportSourcesFromJsonAsync (string jsonString, CancellationToken cancellationToken=default)
 Asynchronously imports sources into winget from a json string.
 
bool ResetSources ()
 Resets all sources that are installed in winget (Needs administrator rights).
 
async Task< bool > ResetSourcesAsync (CancellationToken cancellationToken=default)
 Asynchronously resets all sources that are installed in winget (Needs administrator rights).
 
bool RemoveSources (string name)
 Removes a source from winget (Needs administrator rights).
 
bool RemoveSources (WinGetSource source)
 Removes a source from winget (Needs administrator rights).
 
async Task< bool > RemoveSourcesAsync (string name, CancellationToken cancellationToken=default)
 Asynchronously removes a source from winget (Needs administrator rights).
 
async Task< bool > RemoveSourcesAsync (WinGetSource source, CancellationToken cancellationToken=default)
 Asynchronously removes a source from winget (Needs administrator rights).
 
string SourcesToJson (IEnumerable< WinGetSource > sources)
 Generates a valid json string from the provided sources.
 
- Public Member Functions inherited from WGetNET.WinGet
 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.
 

Additional Inherited Members

- Properties inherited from WGetNET.WinGet
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.WinGetSourceManager class offers methods to manage the sources used by winget.

Definition at line 17 of file WinGetSourceManager.cs.

Constructor & Destructor Documentation

◆ WinGetSourceManager()

WGetNET.WinGetSourceManager.WinGetSourceManager ( )

Initializes a new instance of the WGetNET.WinGetSourceManager class.

Definition at line 22 of file WinGetSourceManager.cs.

Member Function Documentation

◆ AddSource() [1/4]

bool WGetNET.WinGetSourceManager.AddSource ( IEnumerable< WinGetSource > sources)

Adds multiple new sources to winget (Needs administrator rights).

Parameters
sourcesA System.Collections.Generic.IEnumerable<T> of WGetNET.WinGetSource objects to add.
Returns
true if adding all sources was succesfull and false if one or more failed.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentExceptionA provided argument is empty.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 270 of file WinGetSourceManager.cs.

◆ AddSource() [2/4]

bool WGetNET.WinGetSourceManager.AddSource ( string name,
string arg )

Adds a new source to winget (Needs administrator rights).

Parameters
nameA System.String representing the name of the source to add.
argA System.String representing the sources URL or UNC.
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.ArgumentExceptionA provided argument is empty.
System.ArgumentNullExceptionA provided argument is null.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 156 of file WinGetSourceManager.cs.

◆ AddSource() [3/4]

bool WGetNET.WinGetSourceManager.AddSource ( string name,
string arg,
string type )

Adds a new source to winget (Needs administrator rights).

Parameters
nameA System.String representing the name of the source to add.
argA System.String representing the sources URL or UNC.
typeA System.String representing the source type.
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.ArgumentExceptionA provided argument is empty.
System.ArgumentNullExceptionA provided argument is null.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 200 of file WinGetSourceManager.cs.

◆ AddSource() [4/4]

bool WGetNET.WinGetSourceManager.AddSource ( WinGetSource source)

Adds a new source to winget (Needs administrator rights).

Parameters
sourceThe WGetNET.WinGetSource to add.
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.ArgumentExceptionA provided argument is empty.
System.ArgumentNullExceptionA provided argument is null.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 240 of file WinGetSourceManager.cs.

◆ AddSourceAsync() [1/4]

async Task< bool > WGetNET.WinGetSourceManager.AddSourceAsync ( IEnumerable< WinGetSource > sources,
CancellationToken cancellationToken = default )

Asynchronously adds multiple new sources to winget (Needs administrator rights).

The source type is optional but some sources like the "msstore" need it or adding it wil throw an error.

Parameters
sourcesA System.Collections.Generic.IEnumerable<T> of WGetNET.WinGetSource objects to add.
cancellationTokenThe System.Threading.CancellationToken for the System.Threading.Tasks.Task.
Returns
A System.Threading.Tasks.Task, containing the result. The result is true if adding all sources was succesfull and false if one or more failed.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentNullExceptionA provided argument is null.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 443 of file WinGetSourceManager.cs.

◆ AddSourceAsync() [2/4]

async Task< bool > WGetNET.WinGetSourceManager.AddSourceAsync ( string name,
string arg,
CancellationToken cancellationToken = default )

Asynchronously adds a new source to winget (Needs administrator rights).

Parameters
nameA System.String representing the name of the source to add.
argA System.String representing the sources URL or UNC.
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.ArgumentExceptionA provided argument is empty.
System.ArgumentNullExceptionA provided argument is null.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 314 of file WinGetSourceManager.cs.

◆ AddSourceAsync() [3/4]

async Task< bool > WGetNET.WinGetSourceManager.AddSourceAsync ( string name,
string arg,
string type,
CancellationToken cancellationToken = default )

Asynchronously adds a new source to winget (Needs administrator rights).

Parameters
nameA System.String representing the name of the source to add.
argA System.String representing the sources URL or UNC.
typeA System.String representing the source type.
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.ArgumentExceptionA provided argument is empty.
System.ArgumentNullExceptionA provided argument is null.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 362 of file WinGetSourceManager.cs.

◆ AddSourceAsync() [4/4]

async Task< bool > WGetNET.WinGetSourceManager.AddSourceAsync ( WinGetSource source,
CancellationToken cancellationToken = default )

Asynchronously adds a new source to winget (Needs administrator rights).

Parameters
sourceThe WGetNET.WinGetSource to add.
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.ArgumentExceptionA provided argument is empty.
System.ArgumentNullExceptionA provided argument is null.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 406 of file WinGetSourceManager.cs.

◆ ExportSourcesToFile() [1/3]

void WGetNET.WinGetSourceManager.ExportSourcesToFile ( string file)

Exports the winget sources in json format to a file.

If the provided file and/or path does not exist, they will be created.

Parameters
fileThe file for the export.
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 546 of file WinGetSourceManager.cs.

◆ ExportSourcesToFile() [2/3]

void WGetNET.WinGetSourceManager.ExportSourcesToFile ( string file,
string sourceName )

Exports the winget sources in json format to a file.

If the provided file and/or path does not exist, they will be created.

Parameters
fileThe file for the export.
sourceNameThe name of the source for the export.
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 594 of file WinGetSourceManager.cs.

◆ ExportSourcesToFile() [3/3]

void WGetNET.WinGetSourceManager.ExportSourcesToFile ( string file,
WinGetSource source )

Exports the winget sources in json format to a file.

If the provided file and/or path does not exist, they will be created.

Parameters
fileThe file for the export.
sourceThe WGetNET.WinGetSource for the export.
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 647 of file WinGetSourceManager.cs.

◆ ExportSourcesToFileAsync() [1/3]

async Task WGetNET.WinGetSourceManager.ExportSourcesToFileAsync ( string file,
CancellationToken cancellationToken = default )

Asynchronously exports the winget sources in json format to a file.

Parameters
cancellationTokenThe System.Threading.CancellationToken for the System.Threading.Tasks.Task.

If the provided file and/or path does not exist, they will be created.

Returns
The System.Threading.Tasks.Task for the action.
Parameters
fileThe file for the export.
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 697 of file WinGetSourceManager.cs.

◆ ExportSourcesToFileAsync() [2/3]

async Task WGetNET.WinGetSourceManager.ExportSourcesToFileAsync ( string file,
string sourceName,
CancellationToken cancellationToken = default )

Asynchronously exports the winget sources in json format to a file.

Parameters
cancellationTokenThe System.Threading.CancellationToken for the System.Threading.Tasks.Task.

If the provided file and/or path does not exist, they will be created.

Returns
The System.Threading.Tasks.Task for the action.
Parameters
fileThe file for the export.
sourceNameThe name of the source for the export.
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 751 of file WinGetSourceManager.cs.

◆ ExportSourcesToFileAsync() [3/3]

async Task WGetNET.WinGetSourceManager.ExportSourcesToFileAsync ( string file,
WinGetSource source,
CancellationToken cancellationToken = default )

Asynchronously exports the winget sources in json format to a file.

Parameters
cancellationTokenThe System.Threading.CancellationToken for the System.Threading.Tasks.Task.

If the provided file and/or path does not exist, they will be created.

Returns
The System.Threading.Tasks.Task for the action.
Parameters
fileThe file for the export.
sourceThe WGetNET.WinGetSource for the export.
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 811 of file WinGetSourceManager.cs.

◆ GetInstalledSources() [1/2]

List< WinGetSource > WGetNET.WinGetSourceManager.GetInstalledSources ( )

Gets a list of all sources that are installed in winget.

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

Definition at line 37 of file WinGetSourceManager.cs.

◆ GetInstalledSources() [2/2]

List< WinGetSource > WGetNET.WinGetSourceManager.GetInstalledSources ( string sourceName)

Gets a list of installed sources that matches the provided name.

Parameters
sourceNameName of the sources to export.
Returns
A System.Collections.Generic.List<T> of WGetNET.WinGetSource instances.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentExceptionA provided argument is empty.
System.ArgumentNullExceptionA provided argument is null.

Definition at line 60 of file WinGetSourceManager.cs.

◆ GetInstalledSourcesAsync() [1/2]

async Task< List< WinGetSource > > WGetNET.WinGetSourceManager.GetInstalledSourcesAsync ( CancellationToken cancellationToken = default)

Asynchronously gets a list of all sources that are installed in winget.

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.WinGetSource instances.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.

Definition at line 82 of file WinGetSourceManager.cs.

◆ GetInstalledSourcesAsync() [2/2]

async Task< List< WinGetSource > > WGetNET.WinGetSourceManager.GetInstalledSourcesAsync ( string sourceName,
CancellationToken cancellationToken = default )

Asynchronously gets a list of installed sources that matches the provided name.

Parameters
sourceNameName of the sources to export.
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.WinGetSource instances.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentExceptionA provided argument is empty.
System.ArgumentNullExceptionA provided argument is null.

Definition at line 115 of file WinGetSourceManager.cs.

◆ ImportSourcesFromJson()

bool WGetNET.WinGetSourceManager.ImportSourcesFromJson ( string jsonString)

Imports sources into winget from a json string.

Parameters
jsonStringA System.String containing the json for multiple sources.
Returns
true if importing all sources was successful and false if on or more failed.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
WGetNET.Exceptions.InvalidJsonExceptionThe provided JSON could not be deserialized.
System.ArgumentExceptionA provided argument is empty.
System.ArgumentNullExceptionA provided argument is null.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 845 of file WinGetSourceManager.cs.

◆ ImportSourcesFromJsonAsync()

async Task< bool > WGetNET.WinGetSourceManager.ImportSourcesFromJsonAsync ( string jsonString,
CancellationToken cancellationToken = default )

Asynchronously imports sources into winget from a json string.

Parameters
jsonStringA System.String containing the json for multiple sources.
cancellationTokenThe System.Threading.CancellationToken for the System.Threading.Tasks.Task.
Returns
A System.Threading.Tasks.Task, containing the result. The result is true if importing all sources was successful and false if on or more failed.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
WGetNET.Exceptions.InvalidJsonExceptionThe provided JSON could not be deserialized.
System.ArgumentExceptionA provided argument is empty.
System.ArgumentNullExceptionA provided argument is null.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 891 of file WinGetSourceManager.cs.

◆ RemoveSources() [1/2]

bool WGetNET.WinGetSourceManager.RemoveSources ( string name)

Removes a source from winget (Needs administrator rights).

Parameters
nameA System.String representing the name of the source.
Returns
true if the remove was successful or false if the it failed.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentExceptionA provided argument is empty.
System.ArgumentNullExceptionA provided argument is null.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 993 of file WinGetSourceManager.cs.

◆ RemoveSources() [2/2]

bool WGetNET.WinGetSourceManager.RemoveSources ( WinGetSource source)

Removes a source from winget (Needs administrator rights).

Parameters
sourceThe WGetNET.WinGetSource to remove.
Returns
true if the remove was successful or false if the it failed.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentExceptionA provided argument is empty.
System.ArgumentNullExceptionA provided argument is null.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 1023 of file WinGetSourceManager.cs.

◆ RemoveSourcesAsync() [1/2]

async Task< bool > WGetNET.WinGetSourceManager.RemoveSourcesAsync ( string name,
CancellationToken cancellationToken = default )

Asynchronously removes a source from winget (Needs administrator rights).

Parameters
nameA System.String representing the name of the source.
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 remove was successful or false if the it failed.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentExceptionA provided argument is empty.
System.ArgumentNullExceptionA provided argument is null.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 1055 of file WinGetSourceManager.cs.

◆ RemoveSourcesAsync() [2/2]

async Task< bool > WGetNET.WinGetSourceManager.RemoveSourcesAsync ( WinGetSource source,
CancellationToken cancellationToken = default )

Asynchronously removes a source from winget (Needs administrator rights).

Parameters
sourceThe WGetNET.WinGetSource to remove.
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 remove was successful or false if the it failed.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.ArgumentExceptionA provided argument is empty.
System.ArgumentNullExceptionA provided argument is null.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 1089 of file WinGetSourceManager.cs.

◆ ResetSources()

bool WGetNET.WinGetSourceManager.ResetSources ( )

Resets all sources that are installed in winget (Needs administrator rights).

This may take a while depending on the sources.

Returns
true if the reset was successful or false if the it failed.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 937 of file WinGetSourceManager.cs.

◆ ResetSourcesAsync()

async Task< bool > WGetNET.WinGetSourceManager.ResetSourcesAsync ( CancellationToken cancellationToken = default)

Asynchronously resets all sources that are installed in winget (Needs administrator rights).

Parameters
cancellationTokenThe System.Threading.CancellationToken for the System.Threading.Tasks.Task.

This may take a while depending on the sources.

Returns
A System.Threading.Tasks.Task, containing the result. The result is true if the reset was successful or false if the it failed.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.
System.Security.SecurityExceptionThe current user is missing administrator privileges for this call.

Definition at line 963 of file WinGetSourceManager.cs.

◆ SourcesToJson()

string WGetNET.WinGetSourceManager.SourcesToJson ( IEnumerable< WinGetSource > sources)

Generates a valid json string from the provided sources.

Parameters
sourcesThe System.Collections.Generic.IEnumerable<T> of WinGetSource objects.
Returns
A System.String containing the generated json.
Exceptions
System.ArgumentNullExceptionA provided argument is null.

Definition at line 1111 of file WinGetSourceManager.cs.

◆ UpdateSources()

bool WGetNET.WinGetSourceManager.UpdateSources ( )

Updates all sources that are installed in winget.

This may take a while depending on the sources.

Returns
true if the update was successful or false if the it failed.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.

Definition at line 478 of file WinGetSourceManager.cs.

◆ UpdateSourcesAsync()

async Task< bool > WGetNET.WinGetSourceManager.UpdateSourcesAsync ( CancellationToken cancellationToken = default)

Asynchronously updates all sources that are installed in winget.

Parameters
cancellationTokenThe System.Threading.CancellationToken for the System.Threading.Tasks.Task.

This may take a while depending on the sources.

Returns
A System.Threading.Tasks.Task, containing the result. The result is true if the update was successful or false if the it failed.
Exceptions
WGetNET.Exceptions.WinGetNotInstalledExceptionWinGet is not installed or not found on the system.

Definition at line 501 of file WinGetSourceManager.cs.