Class Serialization
The serialization system used by Akka.NET to serialize and deserialize objects per the ActorSystem's serialization configuration.
Inherited Members
Namespace: Akka.Serialization
Assembly: Akka.dll
Syntax
public class Serialization
Constructors
| Edit this page View SourceSerialization(ExtendedActorSystem)
Serialization module. Contains methods for serialization and deserialization as well as locating a Serializer for a particular class as defined in the mapping in the configuration.
Declaration
public Serialization(ExtendedActorSystem system)
Parameters
| Type | Name | Description |
|---|---|---|
| ExtendedActorSystem | system | The ActorSystem to which this serializer belongs. |
Properties
| Edit this page View SourceSystem
The ActorSystem to which Serialization is bound.
Declaration
public ExtendedActorSystem System { get; }
Property Value
| Type | Description |
|---|---|
| ExtendedActorSystem |
Methods
| Edit this page View SourceAddSerializationMap(Type, Serializer)
TBD
Declaration
public void AddSerializationMap(Type type, Serializer serializer)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | type | TBD |
| Serializer | serializer | TBD |
AddSerializer(Serializer)
Adds the serializer to the internal state of the serialization subsystem
Declaration
[Obsolete("No longer supported. Use the AddSerializer(name, serializer) overload instead.", true)]
public void AddSerializer(Serializer serializer)
Parameters
| Type | Name | Description |
|---|---|---|
| Serializer | serializer | Serializer instance |
AddSerializer(string, Serializer)
Adds the serializer to the internal state of the serialization subsystem
Declaration
public void AddSerializer(string name, Serializer serializer)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | Configuration name of the serializer |
| Serializer | serializer | Serializer instance |
Deserialize(byte[], int, string)
Deserializes the given array of bytes using the specified serializer id, using the optional type hint to the Serializer.
Declaration
public object Deserialize(byte[] bytes, int serializerId, string manifest)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | bytes | TBD |
| int | serializerId | TBD |
| string | manifest | TBD |
Returns
| Type | Description |
|---|---|
| object | The resulting object |
Exceptions
| Type | Condition |
|---|---|
| SerializationException | This exception is thrown if the system cannot find the serializer with the given |
Deserialize(byte[], int, Type)
Deserializes the given array of bytes using the specified serializer id, using the optional type hint to the Serializer.
Declaration
public object Deserialize(byte[] bytes, int serializerId, Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | bytes | TBD |
| int | serializerId | TBD |
| Type | type | TBD |
Returns
| Type | Description |
|---|---|
| object | The resulting object |
Exceptions
| Type | Condition |
|---|---|
| SerializationException | This exception is thrown if the system cannot find the serializer with the given |
DeserializeActorRef(string)
Deserializes an IActorRef from its string representation.
Declaration
public IActorRef DeserializeActorRef(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The serialized path of the actor represented as a string. |
Returns
| Type | Description |
|---|---|
| IActorRef | The IActorRef. If no such actor exists, it will be (equivalent to) a dead letter reference. |
FindSerializerFor(object, string)
Returns the Serializer configured for the given object, returns the NullSerializer if it's null.
Declaration
public Serializer FindSerializerFor(object obj, string defaultSerializerName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object that needs to be serialized |
| string | defaultSerializerName | The config name of the serializer to use when no specific binding config is present |
Returns
| Type | Description |
|---|---|
| Serializer | The serializer configured for the given object type |
FindSerializerForType(Type, string)
Returns the configured Serializer for the given Class. The configured Serializer
is used if the configured class IsAssignableFrom from the type, i.e.
the configured class is a super class or implemented interface. In case of
ambiguity it is primarily using the most specific configured class,
and secondly the entry configured first.
Declaration
public Serializer FindSerializerForType(Type objectType, string defaultSerializerName = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | objectType | TBD |
| string | defaultSerializerName | The config name of the serializer to use when no specific binding config is present |
Returns
| Type | Description |
|---|---|
| Serializer | The serializer configured for the given object type |
Exceptions
| Type | Condition |
|---|---|
| SerializationException | This exception is thrown if the serializer of the given |
GetCurrentTransportInformation()
Retrieves the Akka.Serialization.Information used for serializing and deserializing IActorRef instances in all serializers.
Declaration
public static Information GetCurrentTransportInformation()
Returns
| Type | Description |
|---|---|
| Information |
ManifestFor(Serializer, object)
Used to determine the manifest for a message, if applicable.
Declaration
public static string ManifestFor(Serializer s, object msg)
Parameters
| Type | Name | Description |
|---|---|---|
| Serializer | s | The serializer we want to use on the message. |
| object | msg | The message payload. |
Returns
| Type | Description |
|---|---|
| string | A populated string is applicable; Empty otherwise. |
Remarks
WARNING: if you change this method it's likely that the DaemonMsgCreateSerializer and other calls will need changes too.
Serialize(object)
Serializes the given message into an array of bytes using whatever serializer is currently configured.
Declaration
public byte[] Serialize(object o)
Parameters
| Type | Name | Description |
|---|---|---|
| object | o | The message being serialized. |
Returns
| Type | Description |
|---|---|
| byte[] | A byte array containing the serialized message. |
SerializedActorPath(IActorRef)
The serialized path of an actorRef, based on the current transport serialization information. If there is no external address available for the requested address then the systems default address will be used.
If there is no external address available in the given IActorRef then the systems default address will be used and that is retrieved from the ThreadLocal Akka.Serialization.Information that was set with WithTransport<T>(ActorSystem, Address, Func<T>)
Declaration
public static string SerializedActorPath(IActorRef actorRef)
Parameters
| Type | Name | Description |
|---|---|---|
| IActorRef | actorRef | The IActorRef to be serialized. |
Returns
| Type | Description |
|---|---|
| string | Absolute path to the serialized actor. |
WithTransport<T>(ActorSystem, Address, Func<T>)
TBD
Declaration
[Obsolete("Obsolete. Use the SerializeWithTransport<T>(ExtendedActorSystem) method instead.")]
public static T WithTransport<T>(ActorSystem system, Address address, Func<T> action)
Parameters
| Type | Name | Description |
|---|---|---|
| ActorSystem | system | TBD |
| Address | address | TBD |
| Func<T> | action | TBD |
Returns
| Type | Description |
|---|---|
| T | TBD |
Type Parameters
| Name | Description |
|---|---|
| T | TBD |
WithTransport<T>(ExtendedActorSystem, Func<T>)
Performs the requested serialization function while also setting the Akka.Serialization.Serialization.CurrentTransportInformation based on available data from the ActorSystem. Useful when serializing IActorRefs.
Declaration
public static T WithTransport<T>(ExtendedActorSystem system, Func<T> action)
Parameters
| Type | Name | Description |
|---|---|---|
| ExtendedActorSystem | system | The ActorSystem performing serialization. |
| Func<T> | action | The serialization function. |
Returns
| Type | Description |
|---|---|
| T | The serialization output. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of message being serialized. |
WithTransport<TState, T>(ExtendedActorSystem, TState, Func<TState, T>)
Performs the requested serialization function while also setting the Akka.Serialization.Serialization.CurrentTransportInformation based on available data from the ActorSystem. Useful when serializing IActorRefs.
Declaration
public static T WithTransport<TState, T>(ExtendedActorSystem system, TState state, Func<TState, T> action)
Parameters
| Type | Name | Description |
|---|---|---|
| ExtendedActorSystem | system | The ActorSystem performing serialization. |
| TState | state | the other input state to be passed in to the serialization function |
| Func<TState, T> | action | The serialization function. |
Returns
| Type | Description |
|---|---|
| T | The serialization output. |
Type Parameters
| Name | Description |
|---|---|
| TState | The type of caller input state to be used in the function |
| T | The type of message being serialized. |
Edit this page