Class StringSerializer
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
Methods
Configure(IDictionary<string, object>)
Configures this StringSerializer with the given properties.
public void Configure(IDictionary<string, object> properties)
Parameters
propertiesIDictionary<string, object>A dictionary of configuration properties.
Remarks
The default encoding is UTF-8.
Supported configuration properties:
- SolaceSerializerStringEncoding The character encoding to use for serialization. Can be a string encoding name or an Encoding instance.
Exceptions
- ArgumentNullException
Thrown when
propertiesis 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
destinationNamestringThe name of the destination (not used in this implementation).
datastringThe string data to serialize.
headersIDictionary<string, object>Optional headers (not used in this implementation).
Returns
- byte[]
The serialized byte array, or
nullif the inputdataisnull. Returns an empty byte array ifdatais an empty string.
Remarks
The default encoding is UTF-8.