Table of Contents

Class MessageNameHelper

Namespace
Excalibur.Dispatch
Assembly
Excalibur.Dispatch.Abstractions.dll

Reads the stable name a message declares through MessageNameAttribute.

public static class MessageNameHelper
Inheritance
MessageNameHelper
Inherited Members

Remarks

A message's stored identity is declared, never derived. Nothing here falls back to a name taken from the type, because such a name embeds the namespace, assembly and assembly version -- so moving the type, or shipping a new version, would change an identity the consumer never chose and make everything already written unreadable.

Methods

GetDeclaredName(Type)

Gets the stable name type declares, or null if it declares none.

public static string? GetDeclaredName(Type type)

Parameters

type Type

The message type.

Returns

string

The declared name, or null.

Remarks

For a caller that must degrade rather than fail when a message is unnamed. A stored identity is not such a caller -- use GetName(Type) there.

A closed generic composes its name from the name its open definition declares, so one declaration covers every construction and two constructions never claim one name. The composition follows the rule the data contract serializer has used for generic types since .NET 3.0 -- the declared name, the word Of, then the declared name of each type argument, falling back to the argument's type name where it declares none. Drawing<Square, RedBrush> is DrawingOfSquareRedBrush there and here alike.

The hash of argument namespaces that the data contract serializer appends is deliberately not reproduced: it exists to separate two arguments sharing a name in different namespaces, which here is refused loudly at registration rather than accepted silently, and it would make every generic message name unreadable to buy that.

Exceptions

ArgumentNullException

type is null.

GetName(Type)

Gets the stable name type declares.

public static string GetName(Type type)

Parameters

type Type

The message type.

Returns

string

The declared name.

Exceptions

ArgumentNullException

type is null.

InvalidOperationException

type declares no name.