C# Class ChocoPM.Services.LocalChocolateyService

Inheritance: ObservableBase, ILocalChocolateyService
Afficher le fichier Open project: RichiCoder1/ChocoPM

Private Properties

Свойство Type Description
RefreshPackages void
WriteError void
WriteOutput void

Méthodes publiques

Méthode Description
ExecutePackageCommand ( string commandString, bool refreshPackages = true ) : Task

Executes a PowerShell command and returns whether or not there was a result. Optionally calls RefreshPackages.

GetPackages ( bool logOutput = false ) : Task>

Retrives all the local packages.

InstallPackageAsync ( string id, string version = null ) : Task

Install the specific package. Optionally installs a specific version of the package.

IsInstalled ( string id, string version ) : bool

Checks wether the specified package is installed.

This method will only return true if: A) We've already retrieved the local packages and cached them. B) The package is found in the cache. This is to ensure that we're not pulling the local package list until the App specifically request it.

LocalChocolateyService ( IRemoteChocolateyService remoteService ) : System.Collections.ObjectModel
RunPackageCommand ( string commandString, bool refreshPackages = true, bool logOutput = true, bool clearBuffer = true ) : Task>

Executes a PowerShell Command.

UninstallPackageAsync ( string id, string version ) : Task

Uninstall the specified package.

UpdatePackageAsync ( string id ) : Task

Updates the installed package.

Chocolatey does not currently support updating an installed package to a specific version. There's a way to do this (basically uninstall and install specific version), but it's complex and error prone enough that we're avoiding it for now.

Private Methods

Méthode Description
RefreshPackages ( bool logOutput = false ) : void

Invalidates and refreshes the cache.

WriteError ( string message ) : void

Helper function to write error messages to the faux PowerShell console.

WriteOutput ( string message ) : void

Helper function to write output messages to the faux PowerShell console.

Method Details

ExecutePackageCommand() public méthode

Executes a PowerShell command and returns whether or not there was a result. Optionally calls RefreshPackages.
public ExecutePackageCommand ( string commandString, bool refreshPackages = true ) : Task
commandString string The PowerShell command string.
refreshPackages bool Whether to call .
Résultat Task

GetPackages() public méthode

Retrives all the local packages.
public GetPackages ( bool logOutput = false ) : Task>
logOutput bool If true, writes messages out to the faux PowerShell console.
Résultat Task>

InstallPackageAsync() public méthode

Install the specific package. Optionally installs a specific version of the package.
public InstallPackageAsync ( string id, string version = null ) : Task
id string The Id of the package to be isntalled.
version string The specific Version string of the package to be installed.
Résultat Task

IsInstalled() public méthode

Checks wether the specified package is installed.
This method will only return true if: A) We've already retrieved the local packages and cached them. B) The package is found in the cache. This is to ensure that we're not pulling the local package list until the App specifically request it.
public IsInstalled ( string id, string version ) : bool
id string The Id of the package.
version string The Version string of the package.
Résultat bool

LocalChocolateyService() public méthode

public LocalChocolateyService ( IRemoteChocolateyService remoteService ) : System.Collections.ObjectModel
remoteService IRemoteChocolateyService
Résultat System.Collections.ObjectModel

RunPackageCommand() public méthode

Executes a PowerShell Command.
public RunPackageCommand ( string commandString, bool refreshPackages = true, bool logOutput = true, bool clearBuffer = true ) : Task>
commandString string The PowerShell command string.
refreshPackages bool Whether to call .
logOutput bool Whether the output should be logged to the faux PowerShell console or returned as results.
clearBuffer bool Whether the faux PowerShell console should be cleared.
Résultat Task>

UninstallPackageAsync() public méthode

Uninstall the specified package.
public UninstallPackageAsync ( string id, string version ) : Task
id string The Id of the package to be removed.
version string The Version string of the package to be removed.
Résultat Task

UpdatePackageAsync() public méthode

Updates the installed package.
Chocolatey does not currently support updating an installed package to a specific version. There's a way to do this (basically uninstall and install specific version), but it's complex and error prone enough that we're avoiding it for now.
public UpdatePackageAsync ( string id ) : Task
id string The Id of the package.
Résultat Task