Class InterceptorAgent
Base class for all agents that want to intercept a message.
Inherited Members
Namespace: Agents.Net
Assembly: Agents.Net.dll
Syntax
public abstract class InterceptorAgent : Agent
Remarks
Intercepting a message means, that it gets the message before any agent that is consuming the message. It can than do anything with that message - changing it, replacing it, decorating it, ... At the end the interceptor decides whether to publish the intercepted message or not.
Examples
[Intercepts(typeof(InterceptedMessage))]
[Consumes(typeof(ConsumedMessage))]
[Produces(typeof(ProducedMessage))]
public class AgentImplementation : Agent
{
//Implementation
}
Constructors
| Improve this Doc View SourceInterceptorAgent(IMessageBoard, String)
Initialized a new instance of the class InterceptorAgent.
Declaration
protected InterceptorAgent(IMessageBoard messageBoard, string name = null)
Parameters
Type | Name | Description |
---|---|---|
IMessageBoard | messageBoard | The message board to send messages to. |
String | name | Optional name of the agent. The default is the name of the type. |
Remarks
The name
is only used for logging purposes.
Methods
| Improve this Doc View SourceExecuteCore(Message)
The method which should be overridden by the implementation of the agent. It accepts the messages in the same way the Execute(Message) method does.
Declaration
protected override void ExecuteCore(Message messageData)
Parameters
Type | Name | Description |
---|---|---|
Message | messageData | The received message. |
Overrides
| Improve this Doc View SourceIntercept(Message)
This method is called by the message boards to intercept a certain message.
Declaration
public InterceptionAction Intercept(Message messageData)
Parameters
Type | Name | Description |
---|---|---|
Message | messageData | The message that is intercepted. |
Returns
Type | Description |
---|---|
InterceptionAction | The InterceptionAction, which defines whether the original message is published or not. |
Remarks
Only messages which are defined with the InterceptsAttribute are passed to this method.
Only the IMessageBoard should call this. It can also be used in unit tests.
This method executes the InterceptCore(Message) method with the provided message. Additionally it logs all received messages and throw an exception method if the InterceptCore(Message) method throws an exception.
InterceptCore(Message)
The method which should be overridden by the implementation of the agent. It accepts the messages in the same way the Intercept(Message) method does.
Declaration
protected abstract InterceptionAction InterceptCore(Message messageData)
Parameters
Type | Name | Description |
---|---|---|
Message | messageData | The received message. |
Returns
Type | Description |
---|---|
InterceptionAction | The InterceptionAction, which defines whether the original message is published or not. |