Base class for all message objects.

Namespace:  Gallio.Common.Messaging
Assembly:  Gallio (in Gallio.dll) Version: 3.3.0.0 (3.3.459.0)

Syntax

C#
[SerializableAttribute]
public class Message : IValidatable, INormalizable<Message>
Visual Basic (Declaration)
<SerializableAttribute> _
Public Class Message _
	Implements IValidatable, INormalizable(Of Message)

Remarks

Subclasses of this type should be declared to be both XML-serializable (using XmlRootAttribute and XmlTypeAttribute) and binary serializable (using SerializableAttribute). They should also override Validate()()() to validate all message properties. Validation is performed before sending and after receiving messages to enforce basic message integrity constraints that are not checked by the serialization protocol itself.

Message types do not need to be declared in advanced. Consequently plugins may defined their own custom message types as long as they have a distinct name.

Examples

This is an example of a message type.

CopyC#
[Serializable]
[XmlRoot("submitOrderMessage", Namespace = "http://www.fabrikam.org/messages")]
[XmlType(Namespace = "http://www.fabrikam.org/messages")]
public sealed class SubmitOrderMessage : Message
{
    [XmlAttribute("item")]
    public string Item { get; set; }

    [XmlAttribute("quantity")]
    public int Quantity { get; set; }

    public override void Validate()
    {
        ValidationUtils.ValidateNotNull(Item);

        if (Quantity < 1 || Quantity > 10000)
            throw new ValidationException("Quantity should be between 1 and 10000.");
    }
}

Inheritance Hierarchy

See Also