internal static int StepExecuter(IEnumerable <IInstallationStep> procedure, IsCanceledHandler isCanceled, bool bInterruptOnReportError = true)
        {
            try
            {
                foreach (var step in procedure)
                {
                    if (isCanceled())
                    {
                        return(1); // canceled
                    }

                    InstallUtils.SafeCallInterruptable(bInterruptOnReportError, () => step.Init());

                    step.Perform();

                    InstallUtils.SafeCallInterruptable(bInterruptOnReportError, () => step.Report());
                }
            }
            catch (GenericException ex)
            {
                // report installation failure

                InstallUtils.SafeCallInterruptable(false, () => ex.Report());

                return(-1);
            }

            // report success

            return(0);
        }
 public static int RunUpdate(IsCanceledHandler isCanceled, params string[] args)
 {
     CommunicationUtils.CurrentScenario = CommunicationUtils.Scenarion.Update;
     return(StepExecuter(GetUpdateProcedure(args), isCanceled));
 }
 internal static int RunInstallation(IsCanceledHandler isCanceled, params string[] args)
 {
     CommunicationUtils.CurrentScenario = CommunicationUtils.Scenarion.Install;
     return(StepExecuter(GetInstallationProcedure(args), isCanceled));
 }
 internal static int RunUninstall(IsCanceledHandler isCanceled, params string[] args)
 {
     CommunicationUtils.CurrentScenario = CommunicationUtils.Scenarion.Uninstall;
     return(StepExecuter(GetUnInstallationProcedure(args), isCanceled, false)); // uninstall will not fail if the report cannot be sent
 }