Esempio n. 1
0
        public override async Task <bool> InstallAsync()
        {
            // A very basic method of installing a package. It has issues, for example Win32 installers
            // won't be run silently, but it's better than an error.

            // Make sure installer is downloaded
            Guard.IsTrue(Status.IsAtLeast(PackageStatus.Downloaded), nameof(Status));

            bool success = false;

            Models.InstallerType typeReduced = Type.Reduce();
            if (typeReduced == Models.InstallerType.Win32)
            {
                success = await Win32Helper.Install(this);
            }
            else if (typeReduced == Models.InstallerType.Msix)
            {
                success = await PackagedInstallerHelper.Install(this);
            }

            if (success)
            {
                Status = PackageStatus.Installed;
            }
            return(success);
        }
Esempio n. 2
0
        /// <summary>
        /// Determines the <see cref="InstallerType"/> of the downloaded package.
        /// Requires <see cref="PackageBase.Status"/> to be <see cref="PackageStatus.Downloaded"/>.
        /// </summary>
        /// <returns>The file extension that corresponds with the determined <see cref="InstallerType"/>.</returns>
        public async Task <string> GetInstallerType()
        {
            Guard.IsTrue(Status.IsAtLeast(PackageStatus.Downloaded), nameof(Status));

            if (Type == InstallerType.Unknown)
            {
                Type = PackagedInstallerHelper.GetInstallerType((FileInfo)DownloadItem);
            }
            return(Type.GetExtension());
        }
Esempio n. 3
0
 public override async Task <ImageBase> CacheAppIcon()
 {
     try
     {
         Guard.IsTrue(Status.IsAtLeast(PackageStatus.Downloaded), nameof(Status));
         return(PackagedInstallerHelper.GetAppIcon(
                    (FileInfo)DownloadItem, Type.HasFlag(InstallerType.Bundle)));
     }
     catch
     {
         return(TextImage.CreateFromName(Title, ImageType.Logo));
     }
 }
Esempio n. 4
0
 public override async Task <bool> CanLaunchAsync()
 {
     Guard.IsNotNull(PackageFamilyName, nameof(PackageFamilyName));
     try
     {
         return(await PackagedInstallerHelper.IsInstalled(PackageFamilyName));
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine($"Error checking if {PackageFamilyName} is installed. Error:\r\n{ex}");
         return(false);
     }
 }
Esempio n. 5
0
 public override async Task LaunchAsync()
 {
     Guard.IsNotNull(PackageFamilyName, nameof(PackageFamilyName));
     await PackagedInstallerHelper.Launch(PackageFamilyName);
 }
Esempio n. 6
0
 public override async Task <bool> InstallAsync()
 {
     // Make sure installer is downloaded
     Guard.IsTrue(Status.IsAtLeast(PackageStatus.Downloaded), nameof(Status));
     return(await PackagedInstallerHelper.Install(this));
 }
Esempio n. 7
0
 public override async Task <string> GetCannotBeInstalledReason()
 {
     Guard.IsTrue(Status.IsAtLeast(PackageStatus.Downloaded), nameof(Status));
     return(PackagedInstallerHelper.GetCannotBeInstalledReason(
                (FileInfo)DownloadItem, Type.HasFlag(InstallerType.Bundle)));
 }