예제 #1
0
 /// <summary>
 /// If there is anything in the redo stack the top is popped and executed
 /// </summary>
 internal static void Redo()
 {
     if (redoStack.Count > 0)
     {
         Core.ICommand commandrecord = redoStack.Pop();
         Execute(commandrecord);
         redoStackNames.RemoveAt(0);
     }
 }
예제 #2
0
 /// <summary>
 /// All-in-one method to add a command to the stack.
 /// The method will be executed after it's been added to the stack.
 /// </summary>
 /// <param name="cmd">The command record.</param>
 internal static void Execute(Core.ICommand cmd)
 {
     cmd.Redo();
     if (cmd is Core.ICommand)
     {
         undoStack.Push(cmd);
         undoStackNames.Insert(0, cmd.Text);
     }
 }
예제 #3
0
 /// <summary>
 /// If there is anything in the undo stack the top is popped and undone.
 /// </summary>
 internal static void Undo()
 {
     if (undoStack.Count > 0)
     {
         Core.ICommand cmd = undoStack.Pop();
         cmd.Undo();
         undoStackNames.RemoveAt(0);
         redoStack.Push(cmd);
         redoStackNames.Insert(0, cmd.Text);
     }
 }
예제 #4
0
		/// <summary>
		/// Initializes a new instance.
		/// </summary>
		/// <param name="command">The command this instance is associated with.</param>
		internal SurrogateDirect(Core.ICommand command)
		{
			if ((_Command = command) == null) throw new ArgumentNullException(
				"command", "Command cannot be null.");

			if (_Command.Link == null) throw new InvalidOperationException(
				"Link of command '{0}' is null."
				.FormatWith(_Command));

			if (!(_Command.Link is Direct.IDataLink)) throw new InvalidOperationException(
				"Link '{0}' of command '{1}' is not a direct link."
				.FormatWith(_Command.Link, _Command));
		}
예제 #5
0
        /// <summary>
        /// Invoked when disposing or finalizing this instance.
        /// </summary>
        /// <param name="disposing">True if the object is being disposed, false otherwise.</param>
        protected virtual void OnDispose(bool disposing)
        {
            if (disposing)
            {
                if (_DbCommand != null)
                {
                    try { _DbCommand.Cancel(); if (disposing)
                          {
                              _DbCommand.Dispose();
                          }
                    }
                    catch { }
                }
                if (_DataReader != null)
                {
                    try { if (!_DataReader.IsClosed)
                          {
                              _DataReader.Close();
                          }
                          if (disposing)
                          {
                              _DataReader.Dispose();
                          }
                    }
                    catch { }
                }
                if (Link != null)
                {
                    try { if (Link.IsOpen && _LinkOpenedBySurrogate)
                          {
                              Link.Close();
                          }
                    }
                    catch { }
                }
            }

            _DbCommand             = null;
            _DataReader            = null;
            _LinkOpenedBySurrogate = false;

            _Command = null;
            _Schema  = null;

            _IsDisposed = true;
        }
예제 #6
0
        /// <summary>
        /// Initializes a new instance.
        /// </summary>
        /// <param name="command">The command this instance is associated with.</param>
        internal SurrogateDirect(Core.ICommand command)
        {
            if ((_Command = command) == null)
            {
                throw new ArgumentNullException(
                          "command", "Command cannot be null.");
            }

            if (_Command.Link == null)
            {
                throw new InvalidOperationException(
                          "Link of command '{0}' is null."
                          .FormatWith(_Command));
            }

            if (!(_Command.Link is Direct.IDataLink))
            {
                throw new InvalidOperationException(
                          "Link '{0}' of command '{1}' is not a direct link."
                          .FormatWith(_Command.Link, _Command));
            }
        }
예제 #7
0
		/// <summary>
		/// Invoked when disposing or finalizing this instance.
		/// </summary>
		/// <param name="disposing">True if the object is being disposed, false otherwise.</param>
		protected virtual void OnDispose(bool disposing)
		{
			if (disposing)
			{
				if (_DbCommand != null)
				{
					try { _DbCommand.Cancel(); if (disposing) _DbCommand.Dispose(); }
					catch { }
				}
				if (_DataReader != null)
				{
					try { if (!_DataReader.IsClosed) _DataReader.Close(); if (disposing) _DataReader.Dispose(); }
					catch { }
				}
				if (Link != null)
				{
					try { if (Link.IsOpen && _LinkOpenedBySurrogate) Link.Close(); }
					catch { }
				}
			}

			_DbCommand = null;
			_DataReader = null;
			_LinkOpenedBySurrogate = false;

			_Command = null;
			_Schema = null;

			_IsDisposed = true;
		}
예제 #8
0
 protected CommandHandler(Core.ICommand command)
 {
     this.Command = (TCommand)command;
 }