Add a base class for user-defined aggregate factories specialized for specific instantiation of the only one user-defined aggregate. It will reduce the boilerplate code for user, the check for a concrete type. Current custom factory example:
public class BinaryOptionAggregateFactory : IConstructAggregates
{
private readonly IPriceProvider _provider;
public BinaryOptionAggregateFactory(IPriceProvider provider)
{
_provider = provider;
}
public IAggregate Build(Type type, string id, IMemento snapshot = null)
{
if(type == typeof(BinaryOptionGame))
return new BinaryOptionGame(id,_provider);
return AggregateFactory.Default.Build(type, id, snapshot);
}
}
Idea of an improved factory:
public class BinaryOptionAggregateFactory : AggregateFactory<BinaryOptionGame>
{
private readonly IPriceProvider _provider;
public BinaryOptionAggregateFactory(IPriceProvider provider)
{
_provider = provider;
}
public BinaryOptionGame Build(string id, IMemento snapshot = null)
{
return new BinaryOptionGame(id,_provider);
}
}
Add a base class for user-defined aggregate factories specialized for specific instantiation of the only one user-defined aggregate. It will reduce the boilerplate code for user, the check for a concrete type. Current custom factory example:
Idea of an improved factory: