PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/Utilities/ISaveLoadBinary.cs

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