Example #1
0
		internal void Merge(StepResult other)
		{
			if (other.Kind > Kind)
				Kind = other.Kind;
			NeedRestart |= other.NeedRestart;
			NeedSetReferencePhase |= other.NeedSetReferencePhase;
		}
Example #2
0
        private static InstallResult ExecuteContents(IEnumerable <IManifest> manifests, StepVisitor visitor, out int warnings, out int errors)
        {
            warnings = 0;
            int warn;

            errors = 0;

            if (!CustomInstallStep.Invoke(GetMethod <CustomInstallStep>(x => x.OnBeforeInstallContents(default(bool))), visitor.IsProbing, out warn))
            {
                return(ReturnWithErrorResult());
            }
            warnings += warn;

            var contentSteps = new List <ContentInstallStep>();

            foreach (var manifest in manifests)
            {
                contentSteps.AddRange(GetContentSteps(manifest));
            }

            //---- Initialize  contents
            try
            {
                foreach (var step in contentSteps)
                {
                    step.Initialize();
                }
            }
            catch (Exception e)
            {
                Logger.LogException(e, "INITIALIZING ERROR");
                return(ReturnWithErrorResult());
            }

            //---- Install contents
            contentSteps.Sort();
            var postponedContents = new List <ContentInstallStep>();

            foreach (var step in contentSteps)
            {
                try
                {
                    StepResult result = visitor.DoIt(step);
                    if (result.Kind == StepResultKind.Warning)
                    {
                        warnings++;
                    }
                    if (result.Kind == StepResultKind.Error)
                    {
                        return(ReturnWithErrorResult());
                    }
                    if (result.NeedSetReferencePhase)
                    {
                        postponedContents.Add(step);
                    }
                }
                catch (Exception e)
                {
                    Logger.LogException(e);
                    return(ReturnWithErrorResult());
                }
            }
            foreach (var step in postponedContents)
            {
                try
                {
                    StepResult result = step.SetReferences();
                    if (result.Kind == StepResultKind.Warning)
                    {
                        warnings++;
                    }
                    if (result.Kind == StepResultKind.Error)
                    {
                        errors++;
                    }
                }
                catch (Exception e)
                {
                    Logger.LogException(e);
                    return(ReturnWithErrorResult());
                }
            }

            if (!CustomInstallStep.Invoke(GetMethod <CustomInstallStep>(x => x.OnAfterInstallContents(default(bool))), visitor.IsProbing, out warn))
            {
                return(ReturnWithErrorResult());
            }
            warnings += warn;

            return(new InstallResult {
                Successful = true, NeedRestart = false
            });
        }