Description
The SetFavouriteAsync
method is a static extension method for the Sandbox.Package
class. It allows you to asynchronously set or unset a package as a favorite. This method is useful for managing user preferences regarding packages in the Sandbox environment.
Usage
To use the SetFavouriteAsync
method, you need to have a reference to a Sandbox.Package
object. You can then call this method to set or unset the package as a favorite by passing a boolean value.
Parameters:
package
: The Sandbox.Package
instance that you want to mark as a favorite or remove from favorites.
state
: A bool
indicating whether to set (true
) or unset (false
) the package as a favorite.
Returns: A Task
representing the asynchronous operation.
Example
// Example usage of SetFavouriteAsync
Sandbox.Package myPackage = GetPackage(); // Assume GetPackage() retrieves a valid package
bool isFavourite = true; // Set to true to mark as favourite, false to remove from favourites
await SandboxToolExtensions.SetFavouriteAsync(myPackage, isFavourite);