示例#1
0
 protected override void ReadData(DataBuffer buf, FileFormat fmt)
 {
     Index    = buf.ReadInt32();
     Field04h = buf.ReadInt32();
 }
示例#2
0
 /// <summary>
 /// Writes this object's data out to the stream buffer using the
 /// specified file format to define the manner in which data is written.
 /// </summary>
 /// <param name="buf">The buffer to write to.</param>
 /// <param name="fmt">The data format.</param>
 protected abstract void WriteData(DataBuffer buf, FileFormat fmt);
示例#3
0
 /// <summary>
 /// Gets the size of this object's serialized data.
 /// </summary>
 /// <param name="fmt">The data format.</param>
 /// <returns>The size of the object in bytes.</returns>
 protected abstract int GetSize(FileFormat fmt);
示例#4
0
 /// <summary>
 /// Event handler executed after <see cref="WriteData(DataBuffer, FileFormat)"/> is called.
 /// </summary>
 protected virtual void OnWrite(FileFormat fmt)
 {
 }
示例#5
0
 /// <summary>
 /// Reads this object's data in from the stream buffer using the
 /// specified file format to define the manner in which data is read.
 /// </summary>
 /// <param name="buf">The buffer to read from.</param>
 /// <param name="fmt">The data format.</param>
 protected abstract void ReadData(DataBuffer buf, FileFormat fmt);
示例#6
0
 protected override void ReadData(DataBuffer buf, FileFormat fmt)
 {
     FileFormat = fmt;
     LoadAllData(buf);
 }
示例#7
0
 /// <summary>
 /// Event handler executed after <see cref="ReadData(DataBuffer, FileFormat)"/> is called.
 /// </summary>
 protected virtual void OnRead(FileFormat fmt)
 {
 }
示例#8
0
 /// <summary>
 /// Gets the size of a type when serialized using the
 /// specified file format.
 /// </summary>
 /// <typeparam name="T">The type to get the size of.</typeparam>
 /// <param name="fmt">The file format to use.</param>
 /// <returns>The size in bytes of the type.</returns>
 protected static int SizeOfType <T>(FileFormat fmt) where T : new()
 {
     return(Serializer.SizeOfType <T>(fmt));
 }
示例#9
0
 /// <summary>
 /// Gets the size of an object when serialized using the
 /// specified file format.
 /// </summary>
 /// <typeparam name="T">The type to get the size of.</typeparam>
 /// <param name="obj">The object to get the size of.</param>
 /// <param name="fmt">The file format to use.</param>
 /// <returns>The size in bytes of the object.</returns>
 protected static int SizeOfObject <T>(T obj, FileFormat fmt)
 {
     return(Serializer.SizeOfObject(obj, fmt));
 }
示例#10
0
 protected override void WriteData(DataBuffer buf, FileFormat fmt)
 {
     buf.Write((int)Type);
     buf.Write(Handle);
 }
示例#11
0
 int ISaveDataObject.GetSize(FileFormat fmt)
 {
     return(GetSize(fmt));
 }
示例#12
0
 protected override void ReadData(DataBuffer buf, FileFormat fmt)
 {
     Type   = (PoolType)buf.ReadInt32();
     Handle = buf.ReadInt32();
 }
示例#13
0
 /// <summary>
 /// Attempts to determine the file format of the specified save data.
 /// </summary>
 /// <typeparam name="T">The <see cref="SaveFile"/> type.</typeparam>
 /// <param name="data">The data to parse.</param>
 /// <param name="fmt">The detected file format.</param>
 /// <returns>A value indicating whether file format detection was successful.</returns>
 public static bool GetFileFormat <T>(byte[] data, out FileFormat fmt) where T : SaveFile, new()
 {
     return(new T().DetectFileFormat(data, out fmt));
 }
示例#14
0
 protected override void WriteData(DataBuffer buf, FileFormat fmt)
 {
     FileFormat = fmt;
     SaveAllData(buf);
 }
示例#15
0
 protected override void WriteData(DataBuffer buf, FileFormat fmt)
 {
     buf.Write(Index);
     buf.Write(Field04h);
 }
示例#16
0
 /// <summary>
 /// Returns an exception for scenarios when there is no
 /// defined size for the specified file format.
 /// </summary>
 /// <param name="fmt">The file format to use.</param>
 /// <returns>An <see cref="InvalidOperationException"/>.</returns>
 protected InvalidOperationException SizeNotDefined(FileFormat fmt)
 {
     return(new InvalidOperationException(string.Format(Strings.Error_InvalidOperation_SizeNotDefined, fmt.Name)));
 }
示例#17
0
 protected override int GetSize(FileFormat fmt)
 {
     return(16);
 }
示例#18
0
 /// <summary>
 /// Parses the data and determines the file format.
 /// </summary>
 /// <param name="data">The data to parse.</param>
 /// <param name="fmt">The detected file format.</param>
 /// <returns>A value indicating whether the format detection was successful.</returns>
 protected abstract bool DetectFileFormat(byte[] data, out FileFormat fmt);