public void RegisterCommand <TCommand, TResult>() where TCommand : ICommand { if (_isStarted) { throw new ApplicationException("Mosquito is already started. Operation is not permitted"); } else { KnownTypesProvider.RegisterType <TCommand>(); KnownTypesProvider.RegisterCallbackType <TResult>(); } }
public void RegisterCommandHandler <TCommand, THandler>() where TCommand : ICommand where THandler : ICommandHandler <TCommand> { if (Logger.IsDebugEnabled) { Logger.DebugFormat("Registering handler: {0} for command {1}", typeof(THandler).FullName, typeof(TCommand).FullName); } KnownTypesProvider.RegisterType <TCommand>(); _container.Register( Component.For <ICommandHandler <TCommand> >().ImplementedBy <THandler>() ); }