Table of Contents

Class StringSerializer

Namespace
Solace.Serdes
Assembly
Solace.Serdes.dll

A serializer for converting strings to byte[] using a specified character encoding.

public class StringSerializer : ISerializer<string>
Inheritance
StringSerializer
Implements
Inherited Members

Fields

SolaceSerializerStringEncoding

Configuration property key for specifying the string encoding. The value can be a string encoding name (e.g., "UTF-8", "UTF-16") or an Encoding instance.

public const string SolaceSerializerStringEncoding = "solace.serializer.string.encoding"

Field Value

string

Methods

Configure(IDictionary<string, object>)

Configures this StringSerializer with the given properties.

public void Configure(IDictionary<string, object> properties)

Parameters

properties IDictionary<string, object>

A dictionary of configuration properties.

Remarks

The default encoding is UTF-8.

Supported configuration properties:

Exceptions

ArgumentNullException

Thrown when properties is null.

ArgumentException

Thrown when the encoding value is not a valid string or Encoding, or when the specified encoding name is not supported.

Serialize(string, string, IDictionary<string, object>)

Serializes the given string data to a byte array using the configured character encoding.

public byte[] Serialize(string destinationName, string data, IDictionary<string, object> headers = null)

Parameters

destinationName string

The name of the destination (not used in this implementation).

data string

The string data to serialize.

headers IDictionary<string, object>

Optional headers (not used in this implementation).

Returns

byte[]

The serialized byte array, or null if the input data is null. Returns an empty byte array if data is an empty string.

Remarks

The default encoding is UTF-8.