public ModelRouter( object id, TModel model, IPreEventProcessor <TModel> preEventProcessor, IPostEventProcessor <TModel> postEventProcessor, State state, IEventObservationRegistrar eventObservationRegistrar, IModelChangedEventPublisher modelChangedEventPublisher ) { Id = id; _model = model; _preEventProcessor = preEventProcessor; _modelAsPreEventProcessor = model as IPreEventProcessor; _postEventProcessor = postEventProcessor; _modelAsPostEventProcessor = model as IPostEventProcessor; _state = state; _eventObservationRegistrar = eventObservationRegistrar; _modelChangedEventPublisher = modelChangedEventPublisher; }
public void AddModel <TModel>(object modelId, TModel model, IPreEventProcessor <TModel> preEventProcessor, IPostEventProcessor <TModel> postEventProcessor) { Guard.Requires <ArgumentNullException>(modelId != null, "modelId can not be null"); Guard.Requires <ArgumentNullException>(model != null, "model can not be null"); _state.ThrowIfHalted(); var entry = new ModelRouter <TModel>( modelId, model, preEventProcessor, postEventProcessor, _state, _modelsEventsObservations.CreateForModel(modelId), new ModelChangedEventPublisher(this) ); lock (_gate) { Guard.Requires <ArgumentException>(!_modelsById.ContainsKey(modelId), "modelId {0} already registered", modelId); _modelsById.Add(modelId, entry); } }
public void AddModel <TModel>(object modelId, TModel model, IPreEventProcessor <TModel> preEventProcessor) { Guard.Requires <ArgumentNullException>(preEventProcessor != null, "preEventProcessor can not be null"); AddModel(modelId, model, preEventProcessor, null); }