Description
The Fetch
method in the Sandbox.Package
class is a static method used to asynchronously retrieve a package based on its identifier string. This method returns a Task<Package>
, which represents the asynchronous operation of fetching the package.
Usage
To use the Fetch
method, you need to provide two parameters:
identString
(String): The identifier string of the package you want to fetch. This should be a unique identifier that corresponds to a specific package.
partial
(Boolean): A boolean value indicating whether to allow partial fetching of the package. If set to true
, the method may return a partially fetched package if the full package cannot be retrieved.
The method returns a Task<Package>
, which you can await to get the Package
object once the operation completes.
Example
// Example of using the Fetch method to retrieve a package
public async Task RetrievePackageAsync()
{
string packageIdentifier = "example.package.identifier";
bool allowPartialFetch = false;
try
{
Package package = await Package.Fetch(packageIdentifier, allowPartialFetch);
// Use the package object as needed
Console.WriteLine($"Package Title: {package.Title}");
}
catch (Exception ex)
{
// Handle exceptions
Console.WriteLine($"Error fetching package: {ex.Message}");
}
}