Search Results for

    Show / Hide Table of Contents

    Class Agent

    Base class for all agents. It is necessary to inherit this base class in order to receive messages from the IMessageBoard.

    Inheritance
    Object
    Agent
    InterceptorAgent
    Namespace: Agents.Net
    Assembly: Agents.Net.dll
    Syntax
    public abstract class Agent : IDisposable
    Remarks

    The agents must define which messages they want to receive, intercept and which messages they produce. When messages are intercepted it is necessary to use the InterceptorAgent base class.

    Examples
    [Consumes(typeof(ConsumedMessage))]
    [Produces(typeof(ProducedMessage))]
    public class AgentImplementation : Agent
    {
        //Implementation
    }

    Constructors

    | Improve this Doc View Source

    Agent(IMessageBoard)

    Initialized a new instance of the class Agent.

    Declaration
    protected Agent(IMessageBoard messageBoard)
    Parameters
    Type Name Description
    IMessageBoard messageBoard

    The message board to send messages.

    Properties

    | Improve this Doc View Source

    Id

    The id of the agent.

    Declaration
    protected Guid Id { get; }
    Property Value
    Type Description
    Guid
    Remarks

    The id is only used for logging.

    Methods

    | Improve this Doc View Source

    AddDisposable(IDisposable)

    Thread-safely adds an for disposing on Dispose(Boolean)

    Declaration
    protected void AddDisposable(IDisposable disposable)
    Parameters
    Type Name Description
    IDisposable disposable

    The disposable to add.

    | Improve this Doc View Source

    Dispose()

    Declaration
    public void Dispose()
    | Improve this Doc View Source

    Dispose(Boolean)

    Dispose any resources that are stored in the message.

    Declaration
    protected virtual void Dispose(bool disposing)
    Parameters
    Type Name Description
    Boolean disposing

    If true it was called from the Dispose() method.

    | Improve this Doc View Source

    Execute(Message)

    This method is called by the message boards to execute a certain message.

    Declaration
    public void Execute(Message messageData)
    Parameters
    Type Name Description
    Message messageData

    The message data that is executed.

    Remarks

    Only messages which are defined with the ConsumesAttribute are passed to this method. Only the IMessageBoard should call this. It can also be used in unit tests. This method executes the ExecuteCore(Message) method with the provided message. Additionally it logs all received messages and throw an exception method if the ExecuteCore(Message) method throws an exception.

    | Improve this Doc View Source

    ExecuteCore(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 abstract void ExecuteCore(Message messageData)
    Parameters
    Type Name Description
    Message messageData

    The received message.

    | Improve this Doc View Source

    OnMessage(Message)

    This method is used to send a single message to the message board.

    Declaration
    protected void OnMessage(Message message)
    Parameters
    Type Name Description
    Message message

    The message to send.

    Remarks

    The message will be send to the IMessageBoard which was passed in the constructor.

    | Improve this Doc View Source

    OnMessages(IReadOnlyCollection<Message>)

    This method is no deprecated. Please switch to the new SendAndAggregate(IReadOnlyCollection<TStart>, Action<Message>) method.

    Declaration
    protected void OnMessages(IReadOnlyCollection<Message> messages)
    Parameters
    Type Name Description
    IReadOnlyCollection<Message> messages

    All messages to be send.

    Remarks

    The message will be send to the IMessageBoard which was passed in the constructor. To accumulate all messages again it is necessary that all send messages are of the same type.

    • Improve this Doc
    • View Source
    In This Article
    Back to top © Copyright Tobias Wilker and contributors