Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    SerializerExtensions Class

    Namespace: Stride.Core.Serialization
    Assembly: Stride.Core.dll

    Various useful extension methods on top of SerializationStream for serialization/deserialization of common types.

    System.Object → SerializerExtensions
    Derived from SerializerExtensions:

    public static class SerializerExtensions
    Name Description
    Methods
    Clone<T>(T)
    Read<T>(SerializationStream)

    Reads the specified object from the stream.

    ReadBoolean(SerializationStream)

    Reads a boolean value from the stream.

    ReadByte(SerializationStream)

    Reads a unsigned byte integer from the stream.

    ReadBytes(SerializationStream, Int32)

    Reads the specified number of bytes.

    ReadChar(SerializationStream)

    Reads a unicode character from the stream.

    ReadDouble(SerializationStream)

    Reads a 8-byte floating point value from the stream.

    ReadInt16(SerializationStream)

    Reads a 2-byte signed integer from the stream.

    ReadInt32(SerializationStream)

    Reads a 4-byte signed integer from the stream.

    ReadInt64(SerializationStream)

    Reads a 8-byte signed integer from the stream.

    ReadSByte(SerializationStream)

    Reads a signed byte from the stream.

    ReadSingle(SerializationStream)

    Reads a 4-byte floating point value from the stream.

    ReadString(SerializationStream)

    Reads a string.

    ReadUInt16(SerializationStream)

    Reads a 2-byte unsigned integer from the stream.

    ReadUInt32(SerializationStream)

    Reads a 4-byte unsigned integer from the stream.

    ReadUInt64(SerializationStream)

    Reads a 8-byte unsigned integer from the stream.

    Serialize<T>(SerializationStream, ref T, ArchiveMode)

    Serializes the specified object.

    SerializeExtended<T>(SerializationStream, T, ArchiveMode, DataSerializer<T>)

    Serializes the specified object.

    SerializeExtended<T>(SerializationStream, ref T, ArchiveMode, DataSerializer<T>)

    Serializes the specified object.

    Write(SerializationStream, Boolean)

    Writes a boolean value to the specified stream.

    Write(SerializationStream, Byte)

    Writes an unsigned byte to the specified stream.

    Write(SerializationStream, Byte[], Int32, Int32)

    Writes a byte array region to the specified stream.

    Write(SerializationStream, Char)

    Writes a unicode character to the specified stream.

    Write(SerializationStream, Double)

    Writes a 8-byte floating point value to the specified stream.

    Write(SerializationStream, Int16)

    Writes a 2-byte signed integer to the specified stream.

    Write(SerializationStream, Int32)

    Writes a 4-byte signed integer to the specified stream.

    Write(SerializationStream, Int64)

    Writes a 8-byte signed integer to the specified stream.

    Write(SerializationStream, SByte)

    Writes a signed byte to the specified stream.

    Write(SerializationStream, Single)

    Writes a 4-byte floating point value to the specified stream.

    Write(SerializationStream, String)

    Writes a string to the specified stream.

    Write(SerializationStream, UInt16)

    Writes a 2-byte unsigned integer to the specified stream.

    Write(SerializationStream, UInt32)

    Writes a 4-byte unsigned integer to the specified stream.

    Write(SerializationStream, UInt64)

    Writes a 8-byte unsigned integer to the specified stream.

    Write<T>(SerializationStream, T)

    Writes the specified object to the stream.

    | Improve this Doc View Source

    Methods


    Clone<T>(T)

    public static T Clone<T>(T obj)
    Parameters
    Type Name Description
    T obj
    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T

    Read<T>(SerializationStream)

    Reads the specified object from the stream.

    public static T Read<T>(this SerializationStream stream)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream to read the object from.

    Returns
    Type Description
    T

    The object that has just been read.

    Type Parameters
    Name Description
    T

    The type of the object to read.


    ReadBoolean(SerializationStream)

    Reads a boolean value from the stream.

    public static bool ReadBoolean(this SerializationStream stream)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    Returns
    Type Description
    System.Boolean

    A boolean value read from the stream.


    ReadByte(SerializationStream)

    Reads a unsigned byte integer from the stream.

    public static byte ReadByte(this SerializationStream stream)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    Returns
    Type Description
    System.Byte

    An unsigned byte read from the stream.


    ReadBytes(SerializationStream, Int32)

    Reads the specified number of bytes.

    public static byte[] ReadBytes(this SerializationStream stream, int count)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    System.Int32 count
    Returns
    Type Description
    System.Byte[]

    A byte array containing the data read from the stream.


    ReadChar(SerializationStream)

    Reads a unicode character from the stream.

    public static char ReadChar(this SerializationStream stream)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    Returns
    Type Description
    System.Char

    A unicode character read from the stream.


    ReadDouble(SerializationStream)

    Reads a 8-byte floating point value from the stream.

    public static double ReadDouble(this SerializationStream stream)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    Returns
    Type Description
    System.Double

    A 8-byte floating point value read from the stream.


    ReadInt16(SerializationStream)

    Reads a 2-byte signed integer from the stream.

    public static short ReadInt16(this SerializationStream stream)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    Returns
    Type Description
    System.Int16

    A 2-byte signed integer read from the stream.


    ReadInt32(SerializationStream)

    Reads a 4-byte signed integer from the stream.

    public static int ReadInt32(this SerializationStream stream)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    Returns
    Type Description
    System.Int32

    A 4-byte signed integer read from the stream.


    ReadInt64(SerializationStream)

    Reads a 8-byte signed integer from the stream.

    public static long ReadInt64(this SerializationStream stream)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    Returns
    Type Description
    System.Int64

    A 8-byte signed integer read from the stream.


    ReadSByte(SerializationStream)

    Reads a signed byte from the stream.

    public static sbyte ReadSByte(this SerializationStream stream)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    Returns
    Type Description
    System.SByte

    A signed byte read from the stream.


    ReadSingle(SerializationStream)

    Reads a 4-byte floating point value from the stream.

    public static float ReadSingle(this SerializationStream stream)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    Returns
    Type Description
    System.Single

    A 4-byte floating point value read from the stream.


    ReadString(SerializationStream)

    Reads a string.

    public static string ReadString(this SerializationStream stream)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    Returns
    Type Description
    System.String

    A string read from the stream.


    ReadUInt16(SerializationStream)

    Reads a 2-byte unsigned integer from the stream.

    public static ushort ReadUInt16(this SerializationStream stream)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    Returns
    Type Description
    System.UInt16

    A 2-byte unsigned integer read from the stream.


    ReadUInt32(SerializationStream)

    Reads a 4-byte unsigned integer from the stream.

    public static uint ReadUInt32(this SerializationStream stream)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    Returns
    Type Description
    System.UInt32

    A 4-byte unsigned integer read from the stream.


    ReadUInt64(SerializationStream)

    Reads a 8-byte unsigned integer from the stream.

    public static ulong ReadUInt64(this SerializationStream stream)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    Returns
    Type Description
    System.UInt64

    A 8-byte unsigned integer read from the stream.


    Serialize<T>(SerializationStream, ref T, ArchiveMode)

    Serializes the specified object.

    public static void Serialize<T>(this SerializationStream stream, ref T obj, ArchiveMode mode)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream to serialize to.

    T obj

    The object to serialize.

    ArchiveMode mode

    The serialization mode.

    Type Parameters
    Name Description
    T

    SerializeExtended<T>(SerializationStream, T, ArchiveMode, DataSerializer<T>)

    Serializes the specified object.

    public static void SerializeExtended<T>(this SerializationStream stream, T obj, ArchiveMode mode, DataSerializer<T> dataSerializer = null)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream to serialize to.

    T obj

    The object to serialize.

    ArchiveMode mode

    The serialization mode.

    DataSerializer<T> dataSerializer

    The data serializer (can be null).

    Type Parameters
    Name Description
    T

    The object type to serialize.


    SerializeExtended<T>(SerializationStream, ref T, ArchiveMode, DataSerializer<T>)

    Serializes the specified object.

    public static void SerializeExtended<T>(this SerializationStream stream, ref T obj, ArchiveMode mode, DataSerializer<T> dataSerializer = null)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream to serialize to.

    T obj

    The object to serialize.

    ArchiveMode mode

    The serialization mode.

    DataSerializer<T> dataSerializer

    The data serializer (can be null).

    Type Parameters
    Name Description
    T

    The object type to serialize.


    Write(SerializationStream, Boolean)

    Writes a boolean value to the specified stream.

    public static SerializationStream Write(this SerializationStream stream, bool value)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    System.Boolean value

    The boolean value to write.

    Returns
    Type Description
    SerializationStream

    The stream.


    Write(SerializationStream, Byte)

    Writes an unsigned byte to the specified stream.

    public static SerializationStream Write(this SerializationStream stream, byte value)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    System.Byte value

    The unsigned byte to write.

    Returns
    Type Description
    SerializationStream

    The stream.


    Write(SerializationStream, Byte[], Int32, Int32)

    Writes a byte array region to the specified stream.

    public static SerializationStream Write(this SerializationStream stream, byte[] values, int offset, int count)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    System.Byte[] values

    The byte array to write.

    System.Int32 offset

    The starting offset in values to write.

    System.Int32 count

    The number of bytes to write.

    Returns
    Type Description
    SerializationStream

    The stream.


    Write(SerializationStream, Char)

    Writes a unicode character to the specified stream.

    public static SerializationStream Write(this SerializationStream stream, char value)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    System.Char value

    The unicode character to write.

    Returns
    Type Description
    SerializationStream

    The stream.


    Write(SerializationStream, Double)

    Writes a 8-byte floating point value to the specified stream.

    public static SerializationStream Write(this SerializationStream stream, double value)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    System.Double value

    The 8-byte floating point value to write.

    Returns
    Type Description
    SerializationStream

    The stream.


    Write(SerializationStream, Int16)

    Writes a 2-byte signed integer to the specified stream.

    public static SerializationStream Write(this SerializationStream stream, short value)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    System.Int16 value

    The 2-byte signed integer to write.

    Returns
    Type Description
    SerializationStream

    The stream.


    Write(SerializationStream, Int32)

    Writes a 4-byte signed integer to the specified stream.

    public static SerializationStream Write(this SerializationStream stream, int value)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    System.Int32 value

    The 4-byte signed integer to write.

    Returns
    Type Description
    SerializationStream

    The stream.


    Write(SerializationStream, Int64)

    Writes a 8-byte signed integer to the specified stream.

    public static SerializationStream Write(this SerializationStream stream, long value)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    System.Int64 value

    The 8-byte signed integer to write.

    Returns
    Type Description
    SerializationStream

    The stream.


    Write(SerializationStream, SByte)

    Writes a signed byte to the specified stream.

    public static SerializationStream Write(this SerializationStream stream, sbyte value)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    System.SByte value

    The signed byte to write.

    Returns
    Type Description
    SerializationStream

    The stream.


    Write(SerializationStream, Single)

    Writes a 4-byte floating point value to the specified stream.

    public static SerializationStream Write(this SerializationStream stream, float value)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    System.Single value

    The 4-byte floating point value to write.

    Returns
    Type Description
    SerializationStream

    The stream.


    Write(SerializationStream, String)

    Writes a string to the specified stream.

    public static SerializationStream Write(this SerializationStream stream, string value)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    System.String value

    The string to write.

    Returns
    Type Description
    SerializationStream

    The stream.


    Write(SerializationStream, UInt16)

    Writes a 2-byte unsigned integer to the specified stream.

    public static SerializationStream Write(this SerializationStream stream, ushort value)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    System.UInt16 value

    The 2-byte unsigned integer to write.

    Returns
    Type Description
    SerializationStream

    The stream.


    Write(SerializationStream, UInt32)

    Writes a 4-byte unsigned integer to the specified stream.

    public static SerializationStream Write(this SerializationStream stream, uint value)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    System.UInt32 value

    The 4-byte unsigned integer to write.

    Returns
    Type Description
    SerializationStream

    The stream.


    Write(SerializationStream, UInt64)

    Writes a 8-byte unsigned integer to the specified stream.

    public static SerializationStream Write(this SerializationStream stream, ulong value)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream.

    System.UInt64 value

    The 8-byte unsigned integer to write.

    Returns
    Type Description
    SerializationStream

    The stream.


    Write<T>(SerializationStream, T)

    Writes the specified object to the stream.

    public static void Write<T>(this SerializationStream stream, T obj)
    Parameters
    Type Name Description
    SerializationStream stream

    The stream to write the object to.

    T obj

    The object to write.

    Type Parameters
    Name Description
    T

    The type of the object to write.


    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation