Class Serializer
A Serializer represents a bimap between an object and an array of bytes representing that object.
Serializers are loaded using reflection during ActorSystem start-up, where two constructors are tried in order:
- taking exactly one argument of type ExtendedActorSystem; this should be the preferred one because all reflective loading of classes during deserialization should use ExtendedActorSystem.dynamicAccess (see [[akka.actor.DynamicAccess]]), and
- without arguments, which is only an option if the serializer does not load classes using reflection.
Be sure to always use the PropertyManager for loading classes! This is necessary to avoid strange match errors and inequalities which arise from different class loaders loading the same class.
Inheritance
Inherited Members
Namespace: Akka.Serialization
Assembly: Akka.dll
Syntax
public abstract class Serializer
Constructors
| Edit this page View SourceSerializer(ExtendedActorSystem)
Initializes a new instance of the Serializer class.
Declaration
protected Serializer(ExtendedActorSystem system)
Parameters
| Type | Name | Description |
|---|---|---|
| ExtendedActorSystem | system | The actor system to associate with this serializer. |
Fields
| Edit this page View Sourcesystem
The actor system to associate with this serializer.
Declaration
protected readonly ExtendedActorSystem system
Field Value
| Type | Description |
|---|---|
| ExtendedActorSystem |
Properties
| Edit this page View SourceIdentifier
Completely unique value to identify this implementation of Serializer, used to optimize network traffic Values from 0 to 16 is reserved for Akka internal usage
Declaration
public virtual int Identifier { get; }
Property Value
| Type | Description |
|---|---|
| int |
IncludeManifest
Returns whether this serializer needs a manifest in the fromBinary method
Declaration
public abstract bool IncludeManifest { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
| Edit this page View SourceFromBinary(byte[], Type)
Deserializes a byte array into an object of type type.
Declaration
public abstract object FromBinary(byte[] bytes, Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | bytes | The array containing the serialized object |
| Type | type | The type of object contained in the array |
Returns
| Type | Description |
|---|---|
| object | The object contained in the array |
FromBinary<T>(byte[])
Deserializes a byte array into an object.
Declaration
public T FromBinary<T>(byte[] bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | bytes | The array containing the serialized object |
Returns
| Type | Description |
|---|---|
| T | The object contained in the array |
Type Parameters
| Name | Description |
|---|---|
| T |
ToBinary(object)
Serializes the given object into a byte array
Declaration
public abstract byte[] ToBinary(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to serialize |
Returns
| Type | Description |
|---|---|
| byte[] | A byte array containing the serialized object |
ToBinaryWithAddress(Address, object)
Serializes the given object into a byte array and uses the given address to decorate serialized ActorRef's
Declaration
public byte[] ToBinaryWithAddress(Address address, object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| Address | address | The address to use when serializing local ActorRef´s |
| object | obj | The object to serialize |
Returns
| Type | Description |
|---|---|
| byte[] | A byte array containing the serialized object with decorated ActorRef's |
Edit this page