public static DataType LoadDataWithKnownTypeFromMemoryStream <DataType>(MemoryStream data) { data.Seek(0, SeekOrigin.Begin); var reader = new BinaryReader(data); var version = typeof(DataType).Assembly.GetName().Version; return((DataType)BinaryDataLoader.CreateAndLoad(typeof(DataType), reader, version)); }
/// <summary> /// Loads a binary data object and reconstructs the object based on the saved type information. /// </summary> public static object Create(this BinaryReader reader) { if (reader.BaseStream.Position + 6 > reader.BaseStream.Length) { throw new NotEnoughDataLeftInStream(reader.BaseStream.Length); } string shortName = reader.ReadString(); var dataVersion = ReadDataVersionNumber(reader); var type = GetTypeFromShortNameOrFullNameIfNotFound(shortName); return(BinaryDataLoader.CreateAndLoad(type, reader, dataVersion)); }
public static DataType LoadKnownTypeWithoutVersionCheck <DataType>(this BinaryReader reader) { return((DataType)BinaryDataLoader.CreateAndLoad(typeof(DataType), reader, null)); }