private void HandleEvents(PackageWorkingInstallFromCache workingInstallFromCache)
        {
            workingInstallFromCache.OnUpdateCacheStatus += (sender, e) =>
            {
                internalOnUpdateCacheStatus(sender, e);
            };

            workingInstallFromCache.OnQueueInstallAction += (sender, e) =>
            {
                if (this.IsRoot)
                {
                    this.InstallActionsQueue.Enqueue(e.Value);
                }
                else
                {
                    OnQueueInstallAction.Raise(sender, e.Value);
                }
            };

            workingInstallFromCache.OnAddToAllDependencies += (sender, e) =>
            {
                var pair = e.Value;

                if (this.IsRoot)
                {
                    this.AllDependenciesToProcess.Add(pair.Key, pair.Value);
                }
                else
                {
                    OnAddToAllDependencies.Raise(sender, pair);
                }
            };

            workingInstallFromCache.OnAddInstallStatus += (sender, e) =>
            {
                if (this.IsRoot)
                {
                    this.AddInstallStatus(sender, e.InstallFromCache, e.StatusMode, e.Status, e.Args);
                }
                else
                {
                    this.AddInstallStatus(e.InstallFromCache, e.StatusMode, e.Status, e.Args);
                }
            };
        }
 private void ExecuteOrQueue(DirectoryInfo cacheDirectory, DirectoryInfo packageDirectory, Action <DirectoryInfo, DirectoryInfo> action, bool executeDirectly = false)
 {
     if (executeDirectly)
     {
         try
         {
             action(cacheDirectory, packageDirectory);
         }
         catch (Exception ex)
         {
         }
     }
     else
     {
         if (this.IsRoot)
         {
             this.InstallActionsQueue.Enqueue(new InstallAction
             {
                 Action           = action,
                 CacheDirectory   = cacheDirectory,
                 PackageDirectory = packageDirectory,
                 WorkingInstall   = this
             });
         }
         else
         {
             OnQueueInstallAction.Raise(this, new InstallAction
             {
                 Action           = action,
                 CacheDirectory   = cacheDirectory,
                 PackageDirectory = packageDirectory,
                 WorkingInstall   = this
             });
         }
     }
 }