Export (0) Print
Expand All

ServiceEndpoint.Behaviors Property

Gets the behaviors for the service endpoint.

Namespace:  System.ServiceModel.Description
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

'Declaration
Public ReadOnly Property Behaviors As KeyedByTypeCollection(Of IEndpointBehavior)

Property Value

Type: System.Collections.Generic.KeyedByTypeCollection(Of IEndpointBehavior)
The KeyedByTypeCollection(Of TItem) of type IEndpointBehavior that contains the behaviors specified for the service endpoint.

The type of behavior that is accessible from the description hierarchy is scoped to the specific level. From the ServiceEndpoint the IEndpointBehavior is accessible.

If you want access to the IContractBehavior associated with an endpoint, you can obtain the contact for the endpoint using the Contract property. Then call the Behaviors property to obtain the KeyedByTypeCollection(Of TItem) of the IContractBehavior objects associated with the endpoint.

The following code demonstrates how to add a custom endpoint behavior and then access that behavior.

			Dim baseAddress As New Uri("http://localhost:8001/Simple")
			Dim serviceHost As New ServiceHost(GetType(CalculatorService), baseAddress)

			Dim endpoint As ServiceEndpoint = serviceHost.AddServiceEndpoint(GetType(ICalculator), New WSHttpBinding(), "CalculatorServiceObject")

			endpoint.Behaviors.Add(New MyEndpointBehavior())

			Console.WriteLine("List all behaviors:")
			For Each behavior As IEndpointBehavior In endpoint.Behaviors
				Console.WriteLine("Behavior: {0}", CType(behavior, Object).ToString())
			Next behavior

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft