Class MessageSinkMessage
Default implementation of IMessageSinkMessage, with serialization and deserialization support.
public abstract class MessageSinkMessage : IJsonDeserializable, IMessageSinkMessage, IJsonSerializable
- Inheritance
-
MessageSinkMessage
- Implements
- Derived
- Inherited Members
- Extension Methods
Remarks
Because of deserialization, all concrete message sink message types must have a parameterless public constructor that will be used to create the message for deserialization purposes, and must be decorated with JsonTypeIDAttribute to set a unique type ID for deserialization purposes.
Constructors
MessageSinkMessage()
Initializes a new instance of the see MessageSinkMessage class.
protected MessageSinkMessage()
Fields
EmptyTraits
Empty traits, to be used to initialize traits values in messages.
protected static IReadOnlyDictionary<string, IReadOnlyCollection<string>> EmptyTraits
Field Value
UnsetStringPropertyValue
Gets the string value that message properties will return, when a value was not provided during deserialization.
public const string UnsetStringPropertyValue = "<unset>"
Field Value
Methods
Deserialize(IReadOnlyDictionary<string, object?>)
Override to deserialize the values in the dictionary into the message.
protected abstract void Deserialize(IReadOnlyDictionary<string, object?> root)
Parameters
rootIReadOnlyDictionary<string, object>The root of the JSON object
FromJson(IReadOnlyDictionary<string, object?>)
Deserializes the object's values from the provided JSON.
public void FromJson(IReadOnlyDictionary<string, object?> root)
Parameters
rootIReadOnlyDictionary<string, object>The root of the deserialized JSON object
Serialize(JsonObjectSerializer)
Override to serialize the values in the message into JSON.
protected abstract void Serialize(JsonObjectSerializer serializer)
Parameters
serializerJsonObjectSerializerThe serializer to write values to.
ToDisplayString(string?[]?)
Converts a string array into a display value, for use in an ToString() overload.
protected static string ToDisplayString(string?[]? array)
Parameters
arraystring[]
Returns
ToDisplayString<T>(T[]?)
Converts am array into a display value, for use in an ToString() overload.
protected static string ToDisplayString<T>(T[]? array)
Parameters
arrayT[]
Returns
Type Parameters
T
ToJson()
Creates a JSON serialized version of this message.
public string ToJson()
Returns
Exceptions
- InvalidOperationException
Thrown if the message class does not have a JsonTypeIDAttribute.
- UnsetPropertiesException
Thrown when one or more properties are missing values.