public static async Task <Tuple <StorageFile, ToastNotification> > DownloadPackage(ProductDetails product, bool hideProgressToastWhenDone = true, string filepath = null, Action <ProductDetails> gettingPackagesCallback = null, Action <ProductDetails> noPackagesCallback = null, Action <ProductDetails> packagesLoadedCallback = null, Action <ProductDetails, PackageInstance, StorageFile, ToastNotification> packageDownloadedCallback = null) { var culture = CultureInfo.CurrentUICulture; gettingPackagesCallback?.Invoke(product); var dcathandler = new StoreLib.Services.DisplayCatalogHandler(DCatEndpoint.Production, new StoreLib.Services.Locale(culture, true)); await dcathandler.QueryDCATAsync(product.ProductId); var packs = await dcathandler.GetMainPackagesForProductAsync(); string packageFamilyName = dcathandler.ProductListing.Product.Properties.PackageFamilyName; packagesLoadedCallback?.Invoke(product); if (packs != null) { var package = GetLatestDesktopPackage(packs.ToList(), packageFamilyName, product); if (package == null) { noPackagesCallback?.Invoke(product); return(null); } else { var result = await DownloadPackage(package, product, hideProgressToastWhenDone, filepath); if (result != null && result.Item1 != null) { packageDownloadedCallback?.Invoke(product, package, result.Item1, result.Item2); return(result); } } } return(null); }
public static async Task <bool> InstallPackage(ProductDetails product, bool?useAppInstaller = null, Action <ProductDetails> gettingPackagesCallback = null, Action <ProductDetails> noPackagesCallback = null, Action <ProductDetails> packagesLoadedCallback = null, Action <ProductDetails, PackageInstance> packageInstalledCallback = null) { var culture = CultureInfo.CurrentUICulture; gettingPackagesCallback?.Invoke(product); var dcathandler = new StoreLib.Services.DisplayCatalogHandler(DCatEndpoint.Production, new StoreLib.Services.Locale(culture, true)); await dcathandler.QueryDCATAsync(product.ProductId); var packs = await dcathandler.GetMainPackagesForProductAsync(); string packageFamilyName = dcathandler.ProductListing.Product.Properties.PackageFamilyName; packagesLoadedCallback?.Invoke(product); if (packs != null) { var package = GetLatestDesktopPackage(packs.ToList(), packageFamilyName, product); if (package == null) { noPackagesCallback?.Invoke(product); return(false); } else { if (await InstallPackage(package, product, useAppInstaller)) { packageInstalledCallback?.Invoke(product, package); return(true); } } } return(false); }