.NET Framework Class Library
ServiceDescription..::.Behaviors Property

Gets the behaviors associated with the service.

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

Visual Basic (Declaration)
Public ReadOnly Property Behaviors As KeyedByTypeCollection(Of IServiceBehavior)
Visual Basic (Usage)
Dim instance As ServiceDescription
Dim value As KeyedByTypeCollection(Of IServiceBehavior)

value = instance.Behaviors
C#
public KeyedByTypeCollection<IServiceBehavior> Behaviors { get; }
Visual C++
public:
property KeyedByTypeCollection<IServiceBehavior^>^ Behaviors {
    KeyedByTypeCollection<IServiceBehavior^>^ get ();
}
JScript
public function get Behaviors () : KeyedByTypeCollection<IServiceBehavior>

Property Value

Type: System.Collections.Generic..::.KeyedByTypeCollection<(Of <(IServiceBehavior>)>)
The KeyedByTypeCollection<(Of <(TItem>)>) of type IServiceBehavior that contains the behaviors associated with the service.
Remarks

Use this method when adding custom behaviors to extend ServiceHost. Programmatically, you must Add(T) the custom service behavior to the Behaviors prior to when you call the Open method on the ServiceHost object.

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

If you want access to the IEndpointBehavior associated with an endpoint instead, you can obtain the endpoints for the service using the Endpoints property. Then retrieve the ServiceEndpoint from the collection with the Find method that employs the relevant search criteria, and call the Behaviors property to obtain the collection of the IEndpointBehavior objects.

Examples

C#
//// Iterate through the list of behaviors in the ServiceDescription
//ServiceDescription svcDesc = serviceHost.Description;
//KeyedByTypeCollection<IServiceBehavior> sbCol = svcDesc.Behaviors;
//foreach (IServiceBehavior behavior in sbCol)
//{
//    Console.WriteLine("Behavior: {0}", behavior.ToString());
//}
.NET Framework Security

Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, 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.
Version Information

.NET Framework

Supported in: 3.5, 3.0
See Also

Reference

Tags :


Page view tracker