src/Foundation/ServiceModel/Gimela.ServiceModel.ChannelManagement/ServiceIdentity/CustomizedMessageBehavior.cs
/// <summary>
/// Enables inspection or modification of a message before a request message is sent to a service.
/// </summary>
/// <param name="request">The message to be sent to the service.</param>
/// <param name="channel">The  client object channel.</param>
/// <returns>
/// The object that is returned as the  correlationState argument of 
/// the <see cref="M:System.ServiceModel.Dispatcher.IClientMessageInspector.AfterReceiveReply(System.ServiceModel.Channels.Message@,System.Object)"/> 
/// method. This is null if no correlation state is used.The best practice is to make this a <see cref="T:System.Guid"/> 
/// to ensure that no two correlationState objects are the same.
/// </returns>
Enables inspection or modification of a message before a request message is sent to a service.
Enables inspection or modification of a message before a request message is sent to a service .
public object BeforeSendRequest(ref Message request, IClientChannel channel)
    {
      if (MessageHeaderData == null)
      {
        messageHeaderData = new CustomizedMessageHeaderData();
      }
      int index = request.Headers.FindHeader(CustomizedMessageHeaderConstants.MessageHeaderDataName, CustomizedMessageHeaderConstants.MessageHeaderDataNamespace);
      if (index < 0)
      {
        MessageHeader header = MessageHeader.CreateHeader(CustomizedMessageHeaderConstants.MessageHeaderDataName, CustomizedMessageHeaderConstants.MessageHeaderDataNamespace, MessageHeaderData);
        request.Headers.Add(header);
      }
      return null;
    }
public object BeforeSendRequest ( ref Message request , IClientChannel channel ) { if ( MessageHeaderData == null ) { messageHeaderData = new CustomizedMessageHeaderData ( ) ; } int index = request . Headers . FindHeader ( CustomizedMessageHeaderConstants . MessageHeaderDataName , CustomizedMessageHeaderConstants . MessageHeaderDataNamespace ) ; if ( index < 0 ) { MessageHeader header = MessageHeader . CreateHeader ( CustomizedMessageHeaderConstants . MessageHeaderDataName , CustomizedMessageHeaderConstants . MessageHeaderDataNamespace , MessageHeaderData ) ; request . Headers . Add ( header ) ; } return null ; }
Enables inspection or modification of a message before a request message is sent to a service.
Enables inspection or modification of a message before a request message is sent to a service .
// custermize the message header data // modify the message headers before the request message is sent out
The object that is returned as the  correlationState argument of
the
method. This is null if no correlation state is used.The best practice is to make this a
to ensure that no two correlationState objects are the same.
The object that is returned as the correlationState argument of the method . This is null if no correlation state is used . The best practice is to make this a to ensure that no two correlationState objects are the same .
Message
ref
channel
IClientChannel
The  client object channel.
The client object channel .
request
The message to be sent to the service.
The message to be sent to the service .