コード例 #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);
        }
コード例 #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);
            }
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        public void Load(CommandTreeNode node)
        {
            if (node == null || _isLoaded)
            {
                return;
            }

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

                _isLoaded = this.OnLoad(node);
            }
        }
コード例 #5
0
        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;
        }
コード例 #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);
        }
コード例 #7
0
 public CommandTreeNode(string name, CommandTreeNode parent = null) : base(name, parent)
 {
     _children = new CommandTreeNodeCollection(this);
 }
コード例 #8
0
 /// <summary>
 /// 执行加载命令的实际操作。
 /// </summary>
 /// <param name="node">待加载的命令树节点。</param>
 /// <returns>如果加载成功则返回真(true),否则返回假(false)。</returns>
 protected abstract bool OnLoad(CommandTreeNode node);
コード例 #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;
        }
コード例 #10
0
 protected CommandExecutorBase()
 {
     _root = new CommandTreeNode();
 }