public void Remove()
        {
            var removeQueue = new Queue <Package>();

            removeQueue.Enqueue(this);

            UnityRegistryHelper.Remove(removeQueue);
        }
        public IEnumerator FiltratePackages(Queue <Package> packages)
        {
            Debug.Log($"PackageManager FiltratePackages packages {packages.Count}");
            var             installedPackages = UnityRegistryHelper.GetInstalledPackages();
            Queue <Package> packagesForRemove = new Queue <Package>();

            foreach (Package package in packages)
            {
                package.LoadLocalPackageJson();

                var installedPackage = installedPackages.FirstOrDefault(x =>
                {
                    string s = $"{package.packageId}@{package.GetUrl}";
                    //Debug.Log($"---compare {x.packageId} & {s}");

                    return(x.packageId.Equals(s));
                });

                if (installedPackage != null)
                {
                    Debug.Log($"PackageManager found installed package {installedPackage.name}");

                    yield return(EditorCoroutineUtility.StartCoroutineOwnerless(PackageManager.GetPackageFromGit(package, answer =>
                    {
                        package.gitPackage = JsonUtility.FromJson <PackageModel>(answer);
                        //Debug.Log($"PackageManager git package loaded");
                    })));

                    Version installedVersion = new Version(installedPackage.version);
                    Version gitVersion       = new Version(package.gitPackage.version);

                    Debug.Log($"PackageManager gitVersion = {gitVersion} // installedVersion = {installedVersion}");

                    if (gitVersion <= installedVersion)
                    {
                        Debug.Log($"PackageManager version is lower // remove");
                        packagesForRemove.Enqueue(package);
                    }
                }
            }

            var toInstall = new Queue <Package>(packages.Except(packagesForRemove));

            Debug.Log($"PackageManager initial count = {packages.Count} // left = {toInstall.Count}");

            UnityRegistryHelper.OnAddRequestComplete += InstallUnityPackages;
            UnityRegistryHelper.Download(toInstall);
        }
        public void InstallUnityPackages()
        {
            Debug.Log($"InstallUnityPackages // count {unityPackages.Count}");
            if (unityPackages.Count > 0)
            {
                var packageInfo = UnityRegistryHelper.GetInstalledPackage(packageId);

                if (packageInfo != null)
                {
                    UnityPackagesInstaller.Install(unityPackages, packageInfo.resolvedPath);
                }
                else
                {
                    Debug.Log($"Can`t find installed package {packageName}");
                }
            }
        }