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