Click or drag to resize

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.

Inheritance Hierarchy
SystemObject
  EwECorecMessageHandler

Namespace:  EwECore
Assembly:  EwECore (in EwECore.dll) Version: 6.6.15981.0 (6.6.15981.0)
Syntax
public class cMessageHandler : IDisposable

The cMessageHandler type exposes the following members.

Constructors
  NameDescription
Public methodcMessageHandler
Constructs a new cMessageHandler object that will send messages of a given type to the DelegateToCall argument.
Top
Methods
  NameDescription
Public methodDispose
Releases all resources used by the cMessageHandler
Public methodEquals
Test for equality of Delegates.
(Overrides ObjectEquals(Object).)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodValue
Extension method; extract a value from an object by property name.
(Defined by Extensions.)
Top
Remarks

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.

See Also