Paradox Game Engine
v1.0.0 beta06
Main Page
Related Pages
Packages
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Events
Macros
Pages
BinarySerialization.cs
Go to the documentation of this file.
1
// Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2
// This file is distributed under GPL v3. See LICENSE.md for details.
3
using
System.IO;
4
5
namespace
SiliconStudio.Core.Serialization
6
{
7
/// <summary>
8
/// Binary serialization method helpers to easily read/write data from a stream.
9
/// </summary>
10
/// <remarks>
11
/// This class is a simple front end to <see cref="BinarySerializationReader"/> and <see cref="BinarySerializationWriter"/>.
12
/// </remarks>
13
public
class
BinarySerialization
14
{
15
/// <summary>
16
/// Reads an object instance from the specified stream.
17
/// </summary>
18
/// <typeparam name="T">Type of the object to read</typeparam>
19
/// <param name="stream">The stream to read the object instance.</param>
20
/// <returns>An object instance of type T.</returns>
21
public
static
T Read<T>(
Stream
stream)
22
{
23
var reader =
new
BinarySerializationReader
(stream);
24
return
reader.Read<T>();
25
}
26
27
/// <summary>
28
/// Reads an object instance from the specified byte buffer.
29
/// </summary>
30
/// <typeparam name="T">Type of the object to read</typeparam>
31
/// <param name="buffer">The byte buffer to read the object instance.</param>
32
/// <returns>An object instance of type T.</returns>
33
public
static
T Read<T>(byte[] buffer)
34
{
35
var reader =
new
BinarySerializationReader
(
new
MemoryStream(buffer));
36
return
reader.Read<T>();
37
}
38
39
/// <summary>
40
/// Writes an object instance to the specified stream.
41
/// </summary>
42
/// <typeparam name="T">Type of the object to write</typeparam>
43
/// <param name="stream">The stream to write the object instance to.</param>
44
/// <param name="value">The value to write.</param>
45
public
static
void
Write<T>(
Stream
stream, T value)
46
{
47
var writer =
new
BinarySerializationWriter
(stream);
48
writer.Write(value);
49
}
50
}
51
}
Stream
SiliconStudio.Core.Serialization.BinarySerialization
Binary serialization method helpers to easily read/write data from a stream.
Definition:
BinarySerialization.cs:13
SiliconStudio.Core.Serialization.BinarySerializationWriter
Implements SerializationStream as a binary writer.
Definition:
BinarySerializationWriter.cs:12
SiliconStudio.Core.Serialization.BinarySerializationReader
Implements SerializationStream as a binary reader.
Definition:
BinarySerializationReader.cs:12
sources
common
core
SiliconStudio.Core
Serialization
Binary
BinarySerialization.cs
Generated on Sat Dec 20 2014 21:51:11 for Paradox Game Engine by
1.8.7