Can anybody tell me why I only get one object in the accumulator? #71
Replies: 2 comments
-
The accumulator contains one object, because in fact one object of ISetupStep type was created. DI.Setup(nameof(Composition))
.Accumulate<ISetupStep, SetupSteps>(Lifetime.Transient)
.Bind<ISetupStep>().As(Lifetime.Transient).To<LoadConfigs>()
.Bind<ISetupStep>("abc").As(Lifetime.Transient).To<CoreSetupStep>()
.Root<(IReadOnlyCollection<ISetupStep> allSteps, SetupSteps steps)>("Root");
var composition = new Composition();
var root = composition.Root;
var steps = root.steps;
return 0;
internal sealed class SetupSteps : List<ISetupStep>;
internal interface ISetupStep;
internal interface INavigationService;
internal abstract class SetupStep : ISetupStep
{
//protected Composition _composition;
// public SetupStep(Composition composition)
// {
// _composition = composition;
// }
public abstract bool IsComplete();
public abstract Task<bool> RunAsync(Composition composition, INavigationService frame);
}
internal sealed class CoreSetupStep : SetupStep
{
//public CoreSetupStep(Composition composition) : base(composition) { }
public override bool IsComplete()
{
return true;
}
public override async Task<bool> RunAsync(Composition composition, INavigationService frame)
{
//do core setup
return true;
}
}
internal sealed class LoadConfigs : SetupStep
{
// public LoadConfigs(Composition composition) : base(composition) { }
public override bool IsComplete()
{
return false;
// return _composition.Settings == null || _composition.Settings.DbConfig == null || _composition.Settings.SquareConfig == null ||
// _composition.Settings.AzureConfig == null;
}
public override Task<bool> RunAsync(Composition composition, INavigationService frame)
{
//_composition = composition;
//do services setup
return Task.FromResult(IsComplete());
}
} |
Beta Was this translation helpful? Give feedback.
-
Thanks for the explanation! That makes a lot of sense. I will make the relevant changes. |
Beta Was this translation helpful? Give feedback.
-
The objects in question:
Beta Was this translation helpful? Give feedback.
All reactions