예제 #1
0
        public CommandContext(CommandExecutorContext session, CommandExpression expression, ICommand command, object parameter, IDictionary <string, object> extendedProperties = null)
        {
            _session    = session;
            _command    = command ?? throw new ArgumentNullException(nameof(command));
            _parameter  = parameter;
            _expression = expression;

            if (extendedProperties != null && extendedProperties.Count > 0)
            {
                _states = new Dictionary <string, object>(extendedProperties, StringComparer.OrdinalIgnoreCase);
            }
        }
예제 #2
0
        protected CommandContext(CommandContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            _session     = context._session;
            _expression  = context._expression;
            _command     = context._command;
            _commandNode = context._commandNode;
            _parameter   = context._parameter;
            _states      = context._states;
        }
        public CommandExecutorContext(ICommandExecutor executor, CommandExpression expression, object parameter)
        {
            if (executor == null)
            {
                throw new ArgumentNullException(nameof(executor));
            }

            if (expression == null)
            {
                throw new ArgumentNullException(nameof(expression));
            }

            _executor   = executor;
            _expression = expression;
            _parameter  = parameter;
        }
예제 #4
0
        public CommandContext(ICommandExecutor executor, CommandExpression expression, ICommand command, object parameter, IDictionary <string, object> extendedProperties = null)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            _executor   = executor;
            _command    = command;
            _parameter  = parameter;
            _expression = expression;

            if (extendedProperties != null && extendedProperties.Count > 0)
            {
                _extendedProperties = new Dictionary <string, object>(extendedProperties, StringComparer.OrdinalIgnoreCase);
            }
        }
예제 #5
0
        protected virtual object ExecuteCommand(CommandExecutorContext context, CommandExpression expression, CommandTreeNode node, object parameter)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            if (node.Command == null)
            {
                return(null);
            }

            return(node.Command.Execute(this.CreateCommandContext(expression, node, parameter)));
        }
예제 #6
0
        public CommandContext(CommandExecutorContext session, CommandExpression expression, CommandTreeNode commandNode, object parameter, IDictionary <string, object> extendedProperties = null)
        {
            if (commandNode == null)
            {
                throw new ArgumentNullException(nameof(commandNode));
            }

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

            _session     = session;
            _commandNode = commandNode;
            _command     = commandNode.Command;
            _parameter   = parameter;
            _expression  = expression;

            if (extendedProperties != null && extendedProperties.Count > 0)
            {
                _states = new Dictionary <string, object>(extendedProperties, StringComparer.OrdinalIgnoreCase);
            }
        }
예제 #7
0
        public CommandContext(ICommandExecutor executor, CommandExpression expression, 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));
            }

            _executor    = executor;
            _commandNode = commandNode;
            _command     = commandNode.Command;
            _parameter   = parameter;
            _expression  = expression;

            if (extendedProperties != null && extendedProperties.Count > 0)
            {
                _extendedProperties = new Dictionary <string, object>(extendedProperties, StringComparer.OrdinalIgnoreCase);
            }
        }
예제 #8
0
        public CommandExpression Parse(string text)
        {
            if (string.IsNullOrWhiteSpace(text))
            {
                return(null);
            }

            CommandExpression result  = null;
            CommandExpression current = null;

            using (var reader = new StringReader(text))
            {
                while (reader.Peek() > 0)
                {
                    current = Parse(reader);

                    if (result == null)
                    {
                        result = current;
                    }
                    else                     //线性查找命令表达式的管道链,并更新其指向
                    {
                        var previous = result;

                        while (previous.Next != null)
                        {
                            previous = previous.Next;
                        }

                        previous.Next = current;
                    }
                }
            }

            return(result);
        }
예제 #9
0
 protected virtual CommandContext CreateCommandContext(CommandExpression expression, CommandTreeNode node, object parameter)
 {
     return(new CommandContext(this, expression, node, parameter));
 }
예제 #10
0
 protected virtual CommandContext CreateCommandContext(CommandExecutorContext session, CommandExpression expression, CommandTreeNode node, object parameter)
 {
     return(node == null || node.Command == null ? null : new CommandContext(session, expression, node, parameter));
 }
예제 #11
0
 public CommandCompletionContext(ICommandExecutor executor, CommandExpression expression, object parameter, object result, Exception exception = null) : base(executor, expression, parameter)
 {
     _result    = result;
     _exception = exception;
 }