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
| Improve this Doc 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
| Improve this Doc View Sourcesystem
The actor system to associate with this serializer.
Declaration
protected readonly ExtendedActorSystem system
Field Value
Type | Description |
---|---|
ExtendedActorSystem |
Properties
| Improve this Doc 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 |
---|---|
Int32 |
IncludeManifest
Returns whether this serializer needs a manifest in the fromBinary method
Declaration
public abstract bool IncludeManifest { get; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
| Improve this Doc 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[] | TBD |