Esempio n. 1
0
        public StageSeed(IStageSeedConfig config, StageSeedOptions options)
            : base(options?.CancellationToken ?? CancellationToken.None)
        {
            Contracts.Requires.That(config != null);
            Contracts.Requires.That(options != null);

            this.StageIdentity    = config.StageIdentity;
            this.GeneratingPhases = config.PhasesToGenerate.GetIdentities();
            this.phasesToGenerate = config.PhasesToGenerate.AddExceptionFiltering();
            this.postGeneration   = options.PostGeneration ?? new NullAsyncCompletable();

            this.ProgressTotalCount = this.phasesToGenerate.Select(phase => phase.ProgressTotalCount).Sum();

            // Enumerable.Aggregate is used to combine all the phases' progresses into a single observable
            this.Progress = this.phasesToGenerate.Aggregate(
                Observable.Empty <GenerationPhaseProgress>(),
                (progress, phase) => progress
                .Concat(Observable.Return(new GenerationPhaseProgress(
                                              phase, $"Initializing {phase.PhaseIdentity.Name}", 0, this.ProgressTotalCount)))
                .Concat(phase.Progress)
                .Concat(Observable.Return(new GenerationPhaseProgress(
                                              phase, $"Completed {phase.PhaseIdentity.Name}", 0, this.ProgressTotalCount))),
                progress => progress.Accumulate());
        }
Esempio n. 2
0
 public StageSeed(IStageSeedConfig config)
     : this(config, new StageSeedOptions())
 {
 }