Search Results for

    Show / Hide Table of Contents

    Class MessageDecorator

    The base class for message decorators.

    Inheritance
    Object
    Message
    MessageDecorator
    Implements
    IDisposable
    Inherited Members
    Message.Id
    Message.ReplaceWith(Message)
    Message.SetChild(Message)
    Message.Is<T>()
    Message.Get<T>()
    Message.TryGet<T>(T)
    Message.MessageDomain
    Message.ToString()
    Message.DataToString()
    Message.Equals(Message)
    Message.Equals(Object)
    Message.GetHashCode()
    Message.DelayDispose()
    Message.Dispose(Boolean)
    Message.Dispose()
    Message.ToMessageLog()
    Namespace: Agents.Net
    Assembly: Agents.Net.dll
    Syntax
    public abstract class MessageDecorator : Message, IDisposable
    Remarks

    This class is the only way to build a hierarchy of messages. This can be done with an InterceptorAgent or by the message producing agent itself.

    When using Get<T>() the whole hierarchy of message decorators is searched for the specific message type.

    Examples

    This is the recommended way of writing a message decorator:

    public class SpecificMessageDecorator : MessageDecorator
    {
        private SpecificMessageDecorator(Message decoratedMessage, IEnumerable<Message> additionalPredecessors = null) :
            base(decoratedMessage, additionalPredecessors)
        {
        }
    
        public static SpecificMessageDecorator Decorate(DecoratedMessage declaredMessage, IEnumerable<Message> additionalPredecessors = null)
        {
            return new SpecificMessageDecorator(declaredMessage);
        }
    
        protected override string DataToString()
        {
            //maybe log additional data
        }
    }
    
    //Used in client code like this:
    
    SpecificMessageDecorator.Decorate(decoratedMessage);

    Constructors

    | Improve this Doc View Source

    MessageDecorator(Message, IEnumerable<Message>)

    Initializes a new instance of MessageDecorator

    Declaration
    protected MessageDecorator(Message decoratedMessage, IEnumerable<Message> additionalPredecessors = null)
    Parameters
    Type Name Description
    Message decoratedMessage

    The message that should be decorated.

    IEnumerable<Message> additionalPredecessors

    The decoratedMessage is automatically the predecessor of this message. With this parameter additional predecessors can be specified.

    Remarks

    The decoratedMessage is not necessarily the direct Agents.Net.Message.Child of this message, as it is undetermined which message decorator comes first when two decorators are applied at the same time. But it is thread safe to do so.

    Methods

    | Improve this Doc View Source

    IsDecorated(Message)

    Checks whether the message is a decorated message or not.

    Declaration
    public static bool IsDecorated(Message message)
    Parameters
    Type Name Description
    Message message

    The message to check.

    Returns
    Type Description
    Boolean

    true if the message is decorated; otherwise false.

    Remarks

    An example when this method can be used is shown in the FileManipulationBenchmark benchmark test.

    Implements

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