static Task<Package> Fetch( string identString, bool partial )

robot_2Generated
code_blocksInput

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. The method can handle both complete and partial identifiers, depending on the partial parameter.

Usage

To use the Fetch method, you need to provide the identifier string of the package you want to fetch and specify whether the identifier is partial or complete. The method will return a Task that, when awaited, provides the Package object.

Parameters:

  • identString (System.String): The identifier string of the package to fetch. This can be a full or partial identifier.
  • partial (System.Boolean): A boolean indicating whether the identifier is partial. If true, the method will attempt to resolve the partial identifier to a full package.

Example

// Example of using the Fetch method to retrieve a package
async Task FetchPackageExample()
{
    string packageIdentifier = "example.package.id";
    bool isPartial = false; // Set to true if the identifier is partial

    try
    {
        Package package = await Package.Fetch(packageIdentifier, isPartial);
        // Use the package object as needed
        Console.WriteLine($"Package Title: {package.Title}");
    }
    catch (Exception ex)
    {
        // Handle exceptions such as network errors or invalid identifiers
        Console.WriteLine($"Error fetching package: {ex.Message}");
    }
}