Exemple #1
0
        public ExecutionResult ProcessCommand(ICommandBase command)
        {
            ExecutionResult result = null;

            CommandProcessorKey key = new CommandProcessorKey(command.Name);

            //TODO: Не находит соответствия
            ICommandProcessor commandProcessor = this.registeredCommandProcessors[key];

            if (this.registeredCommandNotify.ContainsKey(key))
            {
                ICommandNotifyProcessor notifyHandler = this.registeredCommandNotify[key];

                notifyHandler.BeforeExecute(command);
                commandProcessor.Execute(command);
                //result = commandProcessor.Execute(command);
                notifyHandler.AfterExecute(command);
            }
            else
            {
                //result = commandProcessor.Execute(command);
                commandProcessor.Execute(command);
            }
            return(result);
        }
Exemple #2
0
 public virtual void RegisterCommandProcessor(CommandProcessorKey key, ICommandProcessor processor)
 {
     if (registeredCommandProcessors.ContainsKey(key))
     {
         throw new Exception(string.Format("В коллекции обработчиков ({0}) уже зарегистрирован обработчик с именем {1}", this.Name, key.Name));
     }
     this.registeredCommandProcessors.Add(key, processor);
 }
Exemple #3
0
        public AutoCommandProcessor()
        {
            foreach (CommandProcessorAttribute attributeInfo in this.GetType().GetCustomAttributes())
            {
                CommandProcessorKey key = new CommandProcessorKey(attributeInfo.Name, attributeInfo.ObjectModelName);

                ((CommandsHolder)HoldersCollection.Current[CommandsHolder.HolderName]).RegisterCommandProcessor(key, this);
            }
        }