NanoByte.Common
Static Public Member Functions | List of all members
NanoByte.Common.Storage.BinaryStorage Class Reference

Provides easy serialization to binary files (optionally wrapped in ZIP archives). More...

Static Public Member Functions

static T LoadBinary< T > (Stream stream)
 Loads an object from a binary file. More...
 
static T LoadBinary< T > ([Localizable(false)] string path)
 Loads an object from a binary file. More...
 
static void SaveBinary< T > (this T data, Stream stream)
 Saves an object in a binary stream. More...
 
static void SaveBinary< T > (this T data, [Localizable(false)] string path)
 Saves an object in a binary file. More...
 

Detailed Description

Provides easy serialization to binary files (optionally wrapped in ZIP archives).

Member Function Documentation

◆ LoadBinary< T >() [1/2]

static T NanoByte.Common.Storage.BinaryStorage.LoadBinary< T > ( [Localizable(false)] string  path)
inlinestatic

Loads an object from a binary file.

Template Parameters
TThe type of object the binary stream shall be converted into.
Parameters
pathThe binary file to be loaded.
Returns
The loaded object.
Exceptions
IOExceptionA problem occurred while reading the file.
UnauthorizedAccessExceptionRead access to the file is not permitted.
InvalidDataExceptionA problem occurred while deserializing the binary data.

Uses see cref="AtomicRead"/> internally.

◆ LoadBinary< T >() [2/2]

static T NanoByte.Common.Storage.BinaryStorage.LoadBinary< T > ( Stream  stream)
inlinestatic

Loads an object from a binary file.

Template Parameters
TThe type of object the binary stream shall be converted into.
Parameters
streamThe binary file to be loaded.
Returns
The loaded object.
Exceptions
InvalidDataExceptionA problem occurred while deserializing the binary data.

◆ SaveBinary< T >() [1/2]

static void NanoByte.Common.Storage.BinaryStorage.SaveBinary< T > ( this T  data,
[Localizable(false)] string  path 
)
inlinestatic

Saves an object in a binary file.

This method performs an atomic write operation when possible.

Template Parameters
TThe type of object to be saved in a binary stream.
Parameters
dataThe object to be stored.
pathThe binary file to be written.
Exceptions
IOExceptionA problem occurred while writing the file.
UnauthorizedAccessExceptionWrite access to the file is not permitted.

Uses

See also
AtomicWrite

internally.

◆ SaveBinary< T >() [2/2]

static void NanoByte.Common.Storage.BinaryStorage.SaveBinary< T > ( this T  data,
Stream  stream 
)
static

Saves an object in a binary stream.

Template Parameters
TThe type of object to be saved in a binary stream.
Parameters
dataThe object to be stored.
streamThe binary file to be written.

The documentation for this class was generated from the following file: