Class MessageAction<T1>
A type-dispatching action map that routes an IMessage and one additional argument to a registered callback based on the message's MessageTypeId.
Inherited Members
Namespace: Unity.SimulationPro.Foundation
Assembly: Unity.SimulationPro.Foundation.dll
Syntax
public class MessageAction<T1>
Type Parameters
| Name | Description |
|---|---|
| T1 | The type of the additional argument passed to every callback. |
Methods
Add(MessageTypeId, Action<IMessage, T1>)
Registers a callback for messages with the given MessageTypeId.
Declaration
public void Add(MessageTypeId messageTypeId, Action<IMessage, T1> callback)
Parameters
| Type | Name | Description |
|---|---|---|
| MessageTypeId | messageTypeId | The message type ID to dispatch on. |
| Action<IMessage, T1> | callback | The action to invoke with the message and the additional argument. |
Add<T>(Action<T, T1>)
Registers a strongly-typed callback for messages of type T.
Declaration
public void Add<T>(Action<T, T1> callback) where T : IMessage
Parameters
| Type | Name | Description |
|---|---|---|
| Action<T, T1> | callback | The typed action to invoke when a message of type |
Type Parameters
| Name | Description |
|---|---|
| T | The concrete IMessage type to handle. |
Invoke(IMessage, T1)
Dispatches the message and additional argument to the registered callback.
Declaration
public void Invoke(IMessage msg, T1 arg1)
Parameters
| Type | Name | Description |
|---|---|---|
| IMessage | msg | The message to dispatch. |
| T1 | arg1 | The additional argument to pass to the callback. |
Exceptions
| Type | Condition |
|---|---|
| NotImplementedException | Thrown if no callback is registered for the message type. |