PageRenderTime 100ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/Utilities/ISaveLoadBinary.cs

#
C# | 42 lines | 13 code | 2 blank | 27 comment | 0 complexity | 704a5906b569de90a19b3bc3f7234fab MD5 | raw file
Possible License(s): Apache-2.0
  1. using System.IO;
  2. namespace Delta.Utilities
  3. {
  4. /// <summary>
  5. /// This interface allows saving and loading of an object into and from a
  6. /// byte data stream. For speed and simplicity the BinaryWriter and
  7. /// BinaryReader classes are used to save and load the bytes. This interface
  8. /// is usually used to save and load simple data types inside a larger
  9. /// structure (e.g. scene files, level files, model data, etc. all use
  10. /// Points, Rectangles, Vectors, Matrices, etc.).
  11. /// <para />
  12. /// Please note that some complex classes with safe loading processes will
  13. /// need an additional layer on top of BinaryLoader to make sure data can
  14. /// be loaded even if one of the contained ISaveLoadBinary data types is
  15. /// corrupt. Then the stream is advanced by the number of bytes used and
  16. /// the failed loading of the object is reported, but the rest works fine!
  17. /// <para />
  18. /// Please use Factory.Load and .Save or the Content.Get functionality to
  19. /// create and load classes using this interface. FileHelper.Load and
  20. /// FileHelper.Save are useful functions for this interface.
  21. /// </summary>
  22. public interface ISaveLoadBinary
  23. {
  24. #region Save (Public)
  25. /// <summary>
  26. /// Saves all necessary data of the object into a binary writer stream for
  27. /// the caller to use for saving (or sending over network).
  28. /// </summary>
  29. /// <param name="writer">BinaryWriter for the stream to write into</param>
  30. void Save(BinaryWriter writer);
  31. #endregion
  32. #region Load (Public)
  33. /// <summary>
  34. /// Loads the object again from previously saved data.
  35. /// </summary>
  36. /// <param name="reader">BinaryReader for reading the data</param>
  37. void Load(BinaryReader reader);
  38. #endregion
  39. }
  40. }