Share via


ServiceEndpoint.Behaviors Propiedad

Definición

Obtiene los comportamientos para el punto de conexión de servicio.

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)

Valor de propiedad

KeyedByTypeCollection<IEndpointBehavior>

KeyedByTypeCollection<TItem> de tipo IEndpointBehavior que contiene los comportamientos especificados para el extremo de servicio.

Ejemplos

El código siguiente muestra cómo agregar un comportamiento de extremo personalizado y, a continuación, obtener acceso a ese comportamiento.

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

Comentarios

El ámbito del tipo de comportamiento accesible desde la jerarquía de la descripción debe estar al nivel específico. Desde ServiceEndpoint se puede acceder a IEndpointBehavior.

Si desea tener acceso al IContractBehavior que está asociado con un punto de conexión, puede obtener los contratos de los puntos de conexión mediante la propiedad Contract. A continuación, llame a la propiedad Behaviors para obtener KeyedByTypeCollection<TItem> de los objetos IContractBehavior asociados al punto de conexión.

Se aplica a