Beispiel #1
0
        public static void RegisterExecutorsInAssembly(this CommandService target, Assembly asm)
        {
            var factory = new AttributeBasedMappingFactory();

            foreach (var mappedCommand in asm.GetTypes().Where(t => factory.IsCommandMapped(t)))
            {
                var executor = factory.CreateExecutorForCommand(mappedCommand);
                target.RegisterExecutor(mappedCommand, executor);
            }
        }
        /// <summary>
        /// Executes the command.
        /// </summary>
        /// <param name="command">The command to execute. This should not be null.</param>
        /// <exception cref="ArgumentNullException">Occurs when <i>command</i> is null.</exception>
        void ICommandExecutor <TCommand> .Execute(TCommand command)
        {
            var factory  = new AttributeBasedMappingFactory();
            var executor = factory.CreateExecutorForCommand <TCommand>();

            if (command.GetType().IsDefined(typeof(TransactionalAttribute), true))
            {
                executor = new TransactionalCommandExecutorWrapper <TCommand>(executor);
            }

            executor.Execute(command);
        }