Ejemplo n.º 1
0
        public CommandTreeNode(ICommand command, CommandTreeNode parent = null) : base(command.Name, parent)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            _command  = command;
            _children = new CommandTreeNodeCollection(this);
        }
Ejemplo n.º 2
0
        public CommandContext(ICommandExecutor executor, CommandLine commandLine, CommandTreeNode commandNode, object parameter, IDictionary <string, object> items = null) : base(executor, commandNode, parameter, items)
        {
            _commandLine = commandLine;

            if (commandLine == null)
            {
                _options = new CommandOptionCollection(this.Command);
            }
            else
            {
                _options = new CommandOptionCollection(this.Command, (System.Collections.IDictionary)commandLine.Options);
            }
        }
        protected CommandExecutorContextBase(ICommandExecutor executor, string commandText, CommandTreeNode commandNode, object parameter)
        {
            if (executor == null)
            {
                throw new ArgumentNullException(nameof(executor));
            }

            _executor    = executor;
            _commandText = commandText;
            _commandNode = commandNode;
            _command     = commandNode == null ? null : commandNode.Command;
            _parameter   = parameter;
        }
        public void Load(CommandTreeNode node)
        {
            if (node == null || _isLoaded)
            {
                return;
            }

            lock (_syncRoot)
            {
                if (_isLoaded)
                {
                    return;
                }

                _isLoaded = this.OnLoad(node);
            }
        }
        protected CommandContextBase(ICommandExecutor executor, CommandTreeNode commandNode, object parameter, IDictionary <string, object> extendedProperties = null)
        {
            if (commandNode == null)
            {
                throw new ArgumentNullException("commandNode");
            }

            if (commandNode.Command == null)
            {
                throw new ArgumentException(string.Format("The Command property of '{0}' command-node is null.", commandNode.FullPath));
            }

            _commandNode        = commandNode;
            _command            = commandNode.Command;
            _parameter          = parameter;
            _extendedProperties = extendedProperties;
            _executor           = executor;
        }
Ejemplo n.º 6
0
        private CommandTreeNode FindDown(CommandTreeNode current, Predicate <CommandTreeNode> predicate)
        {
            if (current == null || predicate == null)
            {
                return(null);
            }

            if (predicate(current))
            {
                return(current);
            }

            foreach (var child in current._children)
            {
                if (this.FindDown(child, predicate) != null)
                {
                    return(child);
                }
            }

            return(null);
        }
Ejemplo n.º 7
0
 public CommandTreeNode(string name, CommandTreeNode parent = null) : base(name, parent)
 {
     _children = new CommandTreeNodeCollection(this);
 }
 /// <summary>
 /// 执行加载命令的实际操作。
 /// </summary>
 /// <param name="node">待加载的命令树节点。</param>
 /// <returns>如果加载成功则返回真(true),否则返回假(false)。</returns>
 protected abstract bool OnLoad(CommandTreeNode node);
Ejemplo n.º 9
0
        public CommandExecutorContext(ICommandExecutor executor, CommandLine commandLine, CommandTreeNode commandNode, object parameter) : base(executor, null, commandNode, parameter)
        {
            if (commandLine == null)
            {
                throw new ArgumentNullException(nameof(commandLine));
            }

            _commandLine = commandLine;
        }
 protected CommandExecutorBase()
 {
     _root = new CommandTreeNode();
 }