A context which contains commands that can be executed on an object.
Пример #1
0
        private static bool ExecuteCommand(CommandContext context, List<string> commandAndArgs)
        {
            if (commandAndArgs.Count == 0)
                return true;

            // Look up the command
            var command = context.GetCommand(commandAndArgs[0]);
            if (command == null)
                return false;

            // Execute it
            commandAndArgs.RemoveAt(0);

            try
            {
                ExecuteCommand(command, commandAndArgs);
            }
            catch (Exception e)
            {
                Console.WriteLine("ERROR: " + e.Message);
                ConsoleHistory.Dump("hott_*_crash.log");
            }

            return true;
        }
Пример #2
0
 /// <summary>
 /// Pushes a context onto the stack, making it active.
 /// </summary>
 /// <param name="context">The context to push.</param>
 public void Push(CommandContext context)
 {
     _contextStack.Push(context);
 }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandContext"/> class.
 /// </summary>
 /// <param name="parent">The parent context. Can be <c>null</c> if none.</param>
 /// <param name="name">The context's name.</param>
 public CommandContext(CommandContext parent, string name)
 {
     Parent = parent;
     Name = name;
 }