Пример #1
0
 /// <summary>
 /// Restore the current command context to the state of the previous command context.
 /// </summary>
 public void Restore()
 {
     if (this.PreviousContext != null)
     {
         this.Status = this.PreviousContext.Status;
         this.Command = this.PreviousContext.Command;
         this.Args = this.PreviousContext.Args;
         this.Text = this.PreviousContext.Text;
         this.Prompt = this.PreviousContext.Prompt;
         this.PromptData = this.PreviousContext.PromptData;
         this.PreviousContext = this.PreviousContext.PreviousContext;
     }
     else
     {
         Deactivate();
     }
 }
Пример #2
0
 /// <summary>
 /// Save the current command context as the previous command context.
 /// </summary>
 private void Backup()
 {
     this.PreviousContext = new CommandContext
     {
         Status = this.Status,
         Command = this.Command,
         Args = this.Args,
         Text = this.Text,
         Prompt = this.Prompt,
         PromptData = this.PromptData,
         PreviousContext = this.PreviousContext
     };
 }
Пример #3
0
 /// <summary>
 /// Creates a new instance of the core. Ideally this should be created by Ninject to ensure all dependencies are handled appropriately.
 /// Note: A TerminalBindings class lives in the Terminal.Domain.Ninject.BindingModules namespace. Use this when building your Ninject kernel to ensure proper dependency injection.
 /// 
 /// Sampel: IKernel kernel = new StandardKernel(new TerminalBindings());
 /// </summary>
 /// <param name="commands">A list of all commands available to the application.</param>
 /// <param name="userRepository">The user repository used to retrieve the current user from the database.</param>
 public TerminalCore(
     List<ICommand> commands,
     IUserRepository userRepository,
     IAliasRepository aliasRepository,
     IMessageRepository messageRepository
 )
 {
     _commands = commands;
     _userRepository = userRepository;
     _aliasRepository = aliasRepository;
     _messageRepository = messageRepository;
     this._commandContext = new CommandContext();
 }