Loads a binary data object and reconstructs the object based on the saved type information.
View code on GitHub
Namespace: DeltaEngine.CoreAssembly: DeltaEngine (in DeltaEngine.dll) Version: 1.1.1.0 (1.1.1)
Syntax
Parameters
- reader
- Type: System.IO BinaryReader
Return Value
Type: ObjectUsage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type BinaryReader. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).Remarks
Examples
[Test] public void DynamicallyCreatedTypeIsNotStored() { var unknownObject = new ExpandoObject(); Assert.Throws<BinaryDataExtensions.NoShortNameStoredFor>( () => BinaryDataExtensions.GetShortName(unknownObject)); }
[Test] public void ThereMustBeSomeDataToReadInStream() { var binaryReader = new BinaryReader(new MemoryStream()); Assert.Throws<BinaryDataExtensions.NotEnoughDataLeftInStream>(() => binaryReader.Create()); }
[Test] public void ExpectExceptionForUnreadableData() { var message = new TestMessage { content = "This message cannot be resolved!", ID = 0 }; var memoryStream = new MemoryStream(new byte[64]); var binaryWriter = new BinaryWriter(memoryStream); binaryWriter.Write(BinaryDataExtensions.ToByteArray(message)); memoryStream.Position = 0; var binaryReader = new BinaryReader(memoryStream); Assert.Throws<TypeLoadException>(() => binaryReader.Create()); }
See Also