Provides easy serialization to binary files (optionally wrapped in ZIP archives).
More...
Provides easy serialization to binary files (optionally wrapped in ZIP archives).
◆ 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
-
T | The type of object the binary stream shall be converted into. |
- Parameters
-
path | The binary file to be loaded. |
- Returns
- The loaded object.
- Exceptions
-
IOException | A problem occurred while reading the file. |
UnauthorizedAccessException | Read access to the file is not permitted. |
InvalidDataException | A 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
-
T | The type of object the binary stream shall be converted into. |
- Parameters
-
stream | The binary file to be loaded. |
- Returns
- The loaded object.
- Exceptions
-
InvalidDataException | A 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
-
T | The type of object to be saved in a binary stream. |
- Parameters
-
data | The object to be stored. |
path | The binary file to be written. |
- Exceptions
-
IOException | A problem occurred while writing the file. |
UnauthorizedAccessException | Write 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
-
T | The type of object to be saved in a binary stream. |
- Parameters
-
data | The object to be stored. |
stream | The binary file to be written. |
- Type Constraints
-
T | : | notnull | |
T | : | _serializer.Serialize | |
T | : | stream | |
T | : | throw | |
T | : | new | |
T | : | ArgumentNullException | |
T | : | nameof | |
T | : | stream | |
T | : | data | |
The documentation for this class was generated from the following file:
- Common/Storage/BinaryStorage.cs