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, TResult>() where TCommand : ICommand where THandler : ICommandHandler <TCommand, TResult> where TResult : class { if (Logger.IsDebugEnabled) { Logger.DebugFormat("Registering handler: {0} for command {1} and result type {2}", typeof(THandler).FullName, typeof(TCommand).FullName, typeof(TResult).FullName); } KnownTypesProvider.RegisterType <TCommand>(); KnownTypesProvider.RegisterCallbackType <TResult>(); _container.Register( Component.For <ICommandHandler <TCommand, TResult> >().ImplementedBy <THandler>() ); }