Edit

Share via


MessageFilter.Match Method

Definition

When overridden in a derived class, tests whether a message or a buffered message satisfies the criteria of a filter.

Overloads

Match(Message)

When overridden in a derived class, tests whether a message satisfies the filter criteria. The body cannot be examined.

Match(MessageBuffer)

When overridden in a derived class, tests whether a buffered message satisfies the criteria of a filter.

Remarks

The difference between the two overloads is that one takes a Message parameter and is not permitted to examine the body. The other takes a MessageBuffer parameter and can examine any part of the message. Message headers are automatically buffered and can be inspected by a filter without being consumed. But if the body is to be inspected by a filter, then the entire message must be buffered because an unbuffered message body can be consumed by a query and its contents destroyed.

Use Match if examination of the body is not required. Use Match if examination of the message body is required.

Match(Message)

Source:
MessageFilter.cs
Source:
MessageFilter.cs
Source:
MessageFilter.cs

When overridden in a derived class, tests whether a message satisfies the filter criteria. The body cannot be examined.

public:
 abstract bool Match(System::ServiceModel::Channels::Message ^ message);
public abstract bool Match (System.ServiceModel.Channels.Message message);
abstract member Match : System.ServiceModel.Channels.Message -> bool
Public MustOverride Function Match (message As Message) As Boolean

Parameters

message
Message

The Message object to test.

Returns

true if the Message object satisfies the filter criteria; otherwise, false.

Remarks

This method cannot inspect the contents of the message body.

Notes to Implementers

If the filter attempts to examine the body of an unbuffered message, then the filter must throw an InvalidBodyAccessException. It should not return false.

Applies to

Match(MessageBuffer)

Source:
MessageFilter.cs
Source:
MessageFilter.cs
Source:
MessageFilter.cs

When overridden in a derived class, tests whether a buffered message satisfies the criteria of a filter.

public:
 abstract bool Match(System::ServiceModel::Channels::MessageBuffer ^ buffer);
public abstract bool Match (System.ServiceModel.Channels.MessageBuffer buffer);
abstract member Match : System.ServiceModel.Channels.MessageBuffer -> bool
Public MustOverride Function Match (buffer As MessageBuffer) As Boolean

Parameters

buffer
MessageBuffer

The MessageBuffer object to test.

Returns

true if the MessageBuffer object satisfies the filter criteria; otherwise, false.

Remarks

The message must be fully buffered if the body is to be inspected by the filter. The body of the MessageBuffer is fully buffered and therefore can be inspected by a filter. The body of a Message that has not been fully buffered may be consumed by the filter inspection. The header element of a Message is automatically buffered and therefore can be inspected without being consumed.

Applies to