public DefaultCommandHandlerFactory(ICommandHandlerActivator activator)
 {
     if (activator == null)
     {
         throw new ArgumentNullException(nameof(activator));
     }
     CommandHandlerActivator = activator;
 }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CommandHandlerDescriptor"/> class.
        /// </summary>
        /// <param name="configuration">The <see cref="ProcessorConfiguration"/>.</param>
        /// <param name="commandType">The type of the command.</param>
        /// <param name="handlerType">The type of the handler.</param>
        /// <param name="handleMethod">The <see cref="MethodInfo"/> to be called.</param>
        public CommandHandlerDescriptor(ProcessorConfiguration configuration, Type commandType, Type handlerType, MethodInfo handleMethod)
            : base(configuration, commandType, handlerType)
        {
            this.ReturnType = GetReturnType(handleMethod);
            this.AddAttributesToCache(handleMethod.GetCustomAttributes(true));
            this.actionExecutor   = new Lazy <ActionExecutor>(() => InitializeActionExecutor(handleMethod, commandType));
            this.handlerActivator = this.Configuration.Services.GetHandlerActivator();
            this.QueuePolicy      = this.GetQueuePolicy();

            this.Initialize();
        }
Example #3
0
        private static void CreateCommandHandlerActivatorTracer(ProcessorConfiguration configuration, ITraceWriter traceWriter)
        {
            Contract.Requires(configuration != null);

            ICommandHandlerActivator activator = GetService <ICommandHandlerActivator>(configuration.Services);

            if (activator != null && !(activator is CommandHandlerActivatorTracer))
            {
                CommandHandlerActivatorTracer tracer = new CommandHandlerActivatorTracer(activator, traceWriter);
                configuration.Services.Replace(typeof(ICommandHandlerActivator), tracer);
            }
        }
Example #4
0
 public CommandHandlerRegistry(ICommandHandlerActivator commandHandlerActivator)
 {
     _commandHandlerActivator = commandHandlerActivator ?? throw new ArgumentNullException(nameof(commandHandlerActivator));
     _commandHandlers         = new Dictionary <ICommandHandlerContext, object>();
 }
 public DefaultCommandHandlerFactory()
 {
     CommandHandlerActivator = new DefaultCommandHandlerActivator();
 }