Description
The FetchAsync
method is a static method of the Sandbox.Package
class. It is used to asynchronously fetch a package from the Asset Party service using a specified identifier string. The method returns a Task<Sandbox.Package>
, which represents the asynchronous operation and contains the fetched package upon completion.
Usage
To use the FetchAsync
method, you need to provide two parameters:
identString
(String): The identifier string of the package you want to fetch. This string should uniquely identify the package within the Asset Party service.
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 is asynchronous and should be awaited to ensure that the operation completes before accessing the result.
Example
// Example of using FetchAsync to fetch a package
public async Task FetchPackageExample()
{
string packageIdentifier = "example.package.identifier";
bool allowPartialFetch = false;
try
{
Sandbox.Package package = await Sandbox.Package.FetchAsync(packageIdentifier, allowPartialFetch);
// Use the fetched package
Console.WriteLine($"Package Title: {package.Title}");
}
catch (Exception ex)
{
// Handle exceptions
Console.WriteLine($"Error fetching package: {ex.Message}");
}
}