Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
 ApplyDispatchBehavior Method
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
IOperationBehavior..::.ApplyDispatchBehavior Method

Implements a modification or extension of the service across an operation.

Namespace:  System.ServiceModel.Description
Assembly:  System.ServiceModel (in System.ServiceModel.dll)
Visual Basic (Declaration)
Sub ApplyDispatchBehavior ( _
    operationDescription As OperationDescription, _
    dispatchOperation As DispatchOperation _
)
Visual Basic (Usage)
Dim instance As IOperationBehavior
Dim operationDescription As OperationDescription
Dim dispatchOperation As DispatchOperation

instance.ApplyDispatchBehavior(operationDescription, _
    dispatchOperation)
C#
void ApplyDispatchBehavior(
    OperationDescription operationDescription,
    DispatchOperation dispatchOperation
)
Visual C++
void ApplyDispatchBehavior(
    OperationDescription^ operationDescription, 
    DispatchOperation^ dispatchOperation
)
JScript
function ApplyDispatchBehavior(
    operationDescription : OperationDescription, 
    dispatchOperation : DispatchOperation
)

Parameters

operationDescription
Type: System.ServiceModel.Description..::.OperationDescription
The operation being examined. Use for examination only. If the operation description is modified, the results are undefined.
dispatchOperation
Type: System.ServiceModel.Dispatcher..::.DispatchOperation
The run-time object that exposes customization properties for the operation described by operationDescription.

Implement the ApplyDispatchBehavior method to view, modify, or extend the service runtime across all messages or for a specific operation. For details about what customizations you can do in a service application, see System.ServiceModel.Dispatcher..::.DispatchRuntime and System.ServiceModel.Dispatcher..::.DispatchOperation.

It is recommended that the ApplyDispatchBehavior method throw a NotImplementedException exception if the behavior is only intended for use in a client application.

The following code example shows an implementation of System.ServiceModel.Dispatcher..::.IParameterInspector that writes to the console when the inspector is invoked on an operation. This customization can only be attached to the System.ServiceModel.Dispatcher..::.DispatchOperation or System.ServiceModel.Dispatcher..::.ClientOperation and is therefore usually inserted by an operation behavior.

C#
#region IParameterInspector Members
public void AfterCall(string operationName, object[] outputs, object returnValue, object correlationState)
{
  Console.WriteLine(
    "IParameterInspector.AfterCall called for {0} with return value {1}.", 
    operationName, 
    returnValue.ToString()
  );
}

public object BeforeCall(string operationName, object[] inputs)
{
  Console.WriteLine("IParameterInspector.BeforeCall called for {0}.", operationName);
  return null;
}

The following code example shows how the operation behavior attaches the parameter inspector to the runtime.

C#
#region IOperationBehavior Members
public void AddBindingParameters(
  OperationDescription operationDescription, BindingParameterCollection bindingParameters
)
{ return; }

public void ApplyClientBehavior(OperationDescription operationDescription, ClientOperation clientOperation)
{
  clientOperation.ParameterInspectors.Add(new Inspector());
}

public void ApplyDispatchBehavior(OperationDescription operationDescription, DispatchOperation dispatchOperation)
{
  dispatchOperation.ParameterInspectors.Add(new Inspector());
}

public void Validate(OperationDescription operationDescription){ return; }

Windows Vista, Windows XP SP2, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker