Search Results for

    Show / Hide Table of Contents

    Class Serialization

    The serialization system used by Akka.NET to serialize and deserialize objects per the ActorSystem's serialization configuration.

    Inheritance
    object
    Serialization
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Akka.Serialization
    Assembly: Akka.dll
    Syntax
    public class Serialization

    Constructors

    | Edit this page View Source

    Serialization(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 Source

    System

    The ActorSystem to which Serialization is bound.

    Declaration
    public ExtendedActorSystem System { get; }
    Property Value
    Type Description
    ExtendedActorSystem

    Methods

    | Edit this page View Source

    AddSerializationMap(Type, Serializer)

    TBD

    Declaration
    public void AddSerializationMap(Type type, Serializer serializer)
    Parameters
    Type Name Description
    Type type

    TBD

    Serializer serializer

    TBD

    | Edit this page View Source

    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

    | Edit this page View Source

    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

    | Edit this page View Source

    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 serializerId or it couldn't find the given manifest with the given serializerId.

    | Edit this page View Source

    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 serializerId.

    | Edit this page View Source

    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.

    | Edit this page View Source

    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

    | Edit this page View Source

    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 objectType could not be found.

    | Edit this page View Source

    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
    | Edit this page View Source

    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.

    | Edit this page View Source

    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.

    | Edit this page View Source

    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.

    | Edit this page View Source

    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

    | Edit this page View Source

    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.

    | Edit this page View Source

    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.

    Extension Methods

    ObjectExtensions.IsDefaultForType<T>(T)
    ObjectExtensions.AsOption<T>(T)
    Extensions.AsInstanceOf<T>(object)
    In this article
    • githubEdit this page
    • View Source
    Back to top
    Contribute
    • Project Chat
    • Discussion Forum
    • Source Code
    Support
    • Akka.NET Support Plans
    • Akka.NET Observability Tools
    • Akka.NET Training & Consulting
    Maintained By
    • Petabridge - The Akka.NET Company
    • Learn Akka.NET