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>
        ///// Check if the version of this package instance is greater than the version of the other package instance, or optionally check if equal version.
        ///// </summary>
        ///// <param name="other">The other package to check against, presumably the same GUID.</param>
        ///// <param name="greaterOrEqual">Allow equal to return true?</param>
        ///// <returns><see langword="true"/> if this version is greater than the other package (or equal when <paramref name="greaterOrEqual"/> is <see langword="true"/>),
        ///// otherwise <see langword="false"/>.</returns>
        //public bool IsGreaterVersionThan(PackageManifest other, bool greaterOrEqual = false)
        //{
        //    Version otherVersion;
        //    try
        //    {
        //        otherVersion = new Version(other.version);
        //    }
        //    catch { return true; }

        //    Version thisVersion;
        //    try
        //    {
        //        thisVersion = new Version(this.version);
        //    }
        //    catch { return false; }

        //    return greaterOrEqual
        //            ? thisVersion >= otherVersion
        //            : thisVersion > otherVersion;
        //}

        /// <summary>
        /// Try to enable this package, and optionally all dependencies too.
        /// </summary>
        public bool TryEnable(bool tryEnableDependencies = true)
        {
            return(LocalPackageManager.TryEnablePackage(this.GUID, tryEnableDependencies));
        }