예제 #1
0
        public static bool Equals(Expose left, object right)
        {
            try
            {
                return((bool)left.Call("op_Equality", right).Value);
            }
            catch
            { }

            try
            {
                return(ToDecimal(left) == ToDecimal(right));
            }
            catch
            { }

            try
            {
                return((bool)left.Call("Equals", right).Value);
            }
            catch
            { }

            object lv = ReferenceEquals(left, null) ? null : left.Value;
            object rv = right;

            return(ReferenceEquals(lv, null) ? ReferenceEquals(rv, null) : lv.Equals(rv));
        }
예제 #2
0
        void UpdateGitPackages(Queue <Expose> packagesToUpdate, Dictionary <string, IEnumerable <string> > results = null)
        {
            Debug.LogFormat("[UpdateGitPackages] {0} package(s) left", packagesToUpdate.Count);
            phase = Phase.UpdatePackages;
            bool isRunning = 0 < packagesToUpdate.Count;

            PlaySpinner(isRunning);

            // Update task is finished.
            if (!isRunning)
            {
                Debug.LogFormat("[UpdateGitPackages] Completed");
                // Nothing to do.
                if (results == null)
                {
                    phase = Phase.Idle;
                    return;
                }

                // Update package infomation's version.
                Expose exPackages = GetExposedPackages();
                foreach (var pair in results)
                {
                    try
                    {
                        Debug.LogFormat("[UpdateGitPackages] Overwrite {0}", pair.Key);
                        if (exPackages.Call("ContainsKey", pair.Key).As <bool>())
                        {
                            UpdatePackageInfoVersions(exPackages[pair.Key], pair.Value);
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.LogException(e);
                    }
                }

                // Reload package collection on next frame
                Debug.LogFormat("[UpdateGitPackages] Reload on next frame");
                phase = Phase.ReloadPackageCollection;
                EditorApplication.delayCall += ReloadPackageCollection;
                return;
            }

            if (results == null)
            {
                results = new Dictionary <string, IEnumerable <string> >();
            }

            //
            var package        = packagesToUpdate.Dequeue();
            var displayPackage = package["VersionToDisplay"];
            var packageId      = displayPackage["_PackageId"].As <string>();
            var packageName    = package["packageName"].As <string>();

            // Already get versions.
            if (packageId == null || results.ContainsKey(packageName))
            {
                Debug.LogFormat("[UpdateGitPackages] Skip: {0}", packageName);
                UpdateGitPackages(packagesToUpdate, results);
                return;
            }

            // Get all branch/tag names in repo.
            var url = PackageUtils.GetRepoUrlForCommand(packageId);

            Debug.LogFormat("[UpdateGitPackages] GetRefs: {0}", packageName);
            GitUtils.GetRefs(url, refNames =>
            {
                results[packageName] = refNames;
                UpdateGitPackages(packagesToUpdate, results);
            });
        }