ServiceEndpoint.Behaviors Propriedade

Definição

Obtém os comportamentos do endpoint do serviço.

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 Propriedade

O KeyedByTypeCollection<TItem> tipo IEndpointBehavior of que contém os comportamentos especificados para o endpoint do serviço.

Exemplos

O código seguinte demonstra como adicionar um comportamento de endpoint personalizado e depois aceder a esse comportamento.

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

Observações

O tipo de comportamento acessível a partir da hierarquia de descrição é limitado ao nível específico. A partir ServiceEndpoint do IEndpointBehavior local é acessível.

Se quiser aceder ao IContractBehavior ponto final associado, pode obter o contacto do endpoint usando a Contract propriedade. Depois, chama a Behaviors propriedade para obter o KeyedByTypeCollection<TItem> dos IContractBehavior objetos associados ao endpoint.

Aplica-se a