cMessageHandler Class |
This class is the message handler portion of the Message-Publisher/Message-Handler pattern use to pass messages from the core(publisher) to an interface(handler).
This pattern is based on the Subject/Observer or Publisher/Subscriber patterns. Basically the cMessageHandler provides a wrapper for a delegate in the interface that handles the message. This allows the interface to implement the actual message handling without having to expose its internal structure.
It also allows an interface to split the message handling into a series of smaller routines that only know how to handle one type of message.
Namespace: EwECore
The cMessageHandler type exposes the following members.
Name | Description | |
---|---|---|
cMessageHandler |
Constructs a new cMessageHandler object that will send messages of a given type to the DelegateToCall argument.
|
Name | Description | |
---|---|---|
Dispose | Releases all resources used by the cMessageHandler | |
Equals |
Test for equality of Delegates.
(Overrides ObjectEquals(Object).) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Name | Description | |
---|---|---|
Value |
Extension method; extract a value from an object by property name.
(Defined by Extensions.) |
How to use cMessageHandler:
Define a method in your interface that will do the actual message handling with the same signature as EwECore.cCore.CoreMessageDelegate(cMessage).
Create a cMessageHandler object and in its constructor pass in 3 arguments
1.) The AddressOf the delegate that will handle the message
2.) Source of the message (eCoreComponentType)
3.) The message to handle (eMessageType)
This tells the handler what type of message to handle and where to send the message.
Next
Add the cMessageHandler object to the cCore.Messages.AddMessageHandler(cMessageHandler) interface. This will register the message handler with the core and any messages of this type will be sent to the delegate defined in the interface.
For a default message handler set the eMessageType flag to 'eMessageType.Any'. This handler will be sent any messages that do not have a specific handler.