protected Entity(TAggregateRoot root) { this.root = root; this.state = new TEntityState(); var mapping = new DomainObjectEventHandlerMapping(); foreach (var handlerAction in mapping.GetEventHandlers(() => this.state)) { root.RegisterEventHandler(handlerAction.Key, handlerAction.Value); } }
protected Entity(TAggregateRoot root, IEntityId entityId) { this.root = root; this.state = new TEntityState(); var dynamicState = (dynamic)this.state; dynamicState.EntityId = (dynamic)entityId; var mapping = new DomainObjectEventHandlerMapping(); foreach (var handlerAction in mapping.GetEventHandlers(() => this.state)) { root.RegisterEventHandler(state.EntityId, handlerAction.Key, handlerAction.Value); } }