UndoableCommand.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System;
  4. using System.Runtime.CompilerServices;
  5. using bs;
  6. namespace bs.Editor
  7. {
  8. /// <summary>
  9. /// Base class for implementation of commands that can be recorded in the UndoRedo system.
  10. /// </summary>
  11. public abstract class UndoableCommand : ScriptObject
  12. {
  13. public UndoableCommand()
  14. {
  15. Internal_CreateInstance(this);
  16. }
  17. /// <summary>
  18. /// Applies the command, committing the change.
  19. /// </summary>
  20. protected abstract void Commit();
  21. /// <summary>
  22. /// Reverts the command, reverting the change previously done with <see cref="Commit"/>.
  23. /// </summary>
  24. protected abstract void Revert();
  25. [MethodImpl(MethodImplOptions.InternalCall)]
  26. private static extern void Internal_CreateInstance(UndoableCommand instance);
  27. }
  28. }