Esempio n. 1
0
        /// <summary>
        /// Enable all dependencies for this package, and optionally download and install them if missing.
        /// </summary>
        /// <param name="forceInstall">If true, will download and install missing dependencies.</param>
        /// <returns><see langword="true"/> if successful, otherwise <see langword="false"/>.</returns>
        public bool TryEnableAllDependencies(bool forceInstall)
        {
            bool ret = true;

            if (this.dependencies != null && this.dependencies.Any())
            {
                foreach (var dep in this.dependencies)
                {
                    var pkg = LocalPackageManager.TryGetInstalledPackage(dep);

                    if (pkg == null)
                    {
                        if (!forceInstall)
                        {
                            return(false);
                        }
                        else if (!LocalPackageManager.TryInstallWebPackage(dep, true))
                        {
                            Console.WriteLine("LPM.TryInstallWebPackage return false?");
                            return(false);
                        }
                    }
                    else if (pkg.IsDisabled && !LocalPackageManager.TryEnablePackage(dep))
                    {
                        return(false);
                    }
                }
            }

            return(ret);
        }
Esempio n. 2
0
 /// <summary>
 /// Try to install this package and optionally enable it.
 /// </summary>
 public bool TryInstall(bool andEnable)
 {
     return(LocalPackageManager.TryInstallWebPackage(this.GUID, andEnable));
 }