ServiceEndpoint.Behaviors Propriété

Définition

Obtient les comportements du point de terminaison de service.

public:
 property System::Collections::Generic::KeyedByTypeCollection<System::ServiceModel::Description::IEndpointBehavior ^> ^ Behaviors { System::Collections::Generic::KeyedByTypeCollection<System::ServiceModel::Description::IEndpointBehavior ^> ^ get(); };
public System.Collections.Generic.KeyedByTypeCollection<System.ServiceModel.Description.IEndpointBehavior> Behaviors { get; }
member this.Behaviors : System.Collections.Generic.KeyedByTypeCollection<System.ServiceModel.Description.IEndpointBehavior>
Public ReadOnly Property Behaviors As KeyedByTypeCollection(Of IEndpointBehavior)

Valeur de propriété

KeyedByTypeCollection<IEndpointBehavior>

KeyedByTypeCollection<TItem> de type IEndpointBehavior qui contient les comportements spécifiés pour le point de terminaison de service.

Exemples

Le code suivant illustre l'ajout d'un comportement de point de terminaison puis son accès :

Uri baseAddress = new Uri("http://localhost:8001/Simple");
ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress);

ServiceEndpoint endpoint = serviceHost.AddServiceEndpoint(
    typeof(ICalculator),
    new WSHttpBinding(),
    "CalculatorServiceObject");

endpoint.Behaviors.Add(new MyEndpointBehavior());

Console.WriteLine("List all behaviors:");
foreach (IEndpointBehavior behavior in endpoint.Behaviors)
{
    Console.WriteLine("Behavior: {0}", behavior.ToString());
}
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

Remarques

Le type de comportement qui est accessible à partir de la hiérarchie de description est inclus à la portée du niveau spécifique. À partir de la ServiceEndpoint, le IEndpointBehavior est accessible.

Si vous voulez accéder à IContractBehavior associé à un point de terminaison, vous pouvez retrouver le contact de ce dernier à l'aide de la propriété Contract. Appelez ensuite la propriété Behaviors pour obtenir la KeyedByTypeCollection<TItem> des objets IContractBehavior associés au point de terminaison.

S’applique à