static bool TryGetCached( string identString, Sandbox.Package& package, bool allowPartial )

book_4_sparkGenerated
code_blocksInput

Description

The TryGetCached method attempts to retrieve a cached package based on the provided identifier string. It is a static method of the Package class in the Sandbox namespace. This method is useful for checking if a package is already cached locally, which can improve performance by avoiding unnecessary network requests.

Usage

To use the TryGetCached method, provide the identifier string of the package you want to check, a reference to a Package object to store the result, and a boolean indicating whether partial matches are allowed. The method returns true if the package is found in the cache, otherwise it returns false.

Parameters:

  • identString (System.String): The identifier string of the package to look for in the cache.
  • package (out Sandbox.Package): An output parameter that will hold the cached package if found.
  • allowPartial (System.Boolean): A boolean indicating whether partial matches are acceptable.

Example

// Example usage of TryGetCached method
string packageIdentifier = "example.package.id";
Package cachedPackage;
bool allowPartialMatch = false;

bool isCached = Package.TryGetCached(packageIdentifier, out cachedPackage, allowPartialMatch);

if (isCached)
{
    // Use the cachedPackage as needed
    Console.WriteLine($"Package '{cachedPackage.Title}' is cached.");
}
else
{
    // Handle the case where the package is not cached
    Console.WriteLine("Package is not cached.");
}