Sdílet prostřednictvím


ServiceEndpoint.Behaviors Vlastnost

Definice

Získá chování koncového bodu služby.

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)

Hodnota vlastnosti

KeyedByTypeCollection<IEndpointBehavior>

Typ KeyedByTypeCollection<TItem> IEndpointBehavior , který obsahuje chování zadané pro koncový bod služby.

Příklady

Následující kód ukazuje, jak přidat vlastní chování koncového bodu a pak k tomuto chování přistupovat.

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

Poznámky

Typ chování, které je přístupné z hierarchie popisu, je vymezen na konkrétní úroveň. Z místa ServiceEndpoint IEndpointBehavior je přístupná.

Pokud chcete získat přístup k IContractBehavior přidruženému ke koncovému bodu, můžete získat kontakt pro koncový bod pomocí Contract vlastnosti. Potom zavolejte Behaviors vlastnost, abyste získali KeyedByTypeCollection<TItem> IContractBehavior objekty přidružené ke koncovému bodu.

Platí pro