public Collection(TRootQueryModel aggregate) { _aggregate = aggregate; _aggregate.RegisterEventAppliers() .For <TEntityCreatedEventInterface>( e => { var component = (TEntitity)Activator.CreateInstance(typeof(TEntitity), nonPublic: true); component.RootQueryModel = _aggregate; _entities.Add(IdGetter.GetId(e), component); _entitiesInCreationOrder.Add(component); }) .For <TEntityBaseEventInterface>(e => _entities[IdGetter.GetId(e)].ApplyEvent(e)); }
public static IReadOnlyEntityCollection <TEntitity, TEntityId> CreateSelfManagingCollection(TRootQueryModel rootQueryModel) => new Collection(rootQueryModel);