ServiceEndpoint.Behaviors Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the behaviors for the service endpoint.
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)
Property Value
The KeyedByTypeCollection<TItem> of type IEndpointBehavior that contains the behaviors specified for the service endpoint.
Examples
The following code demonstrates how to add a custom endpoint behavior and then access that behavior.
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
Remarks
The type of behavior that is accessible from the description hierarchy is scoped to the specific level. From the ServiceEndpoint the IEndpointBehavior is accessible.
If you want access to the IContractBehavior associated with an endpoint, you can obtain the contact for the endpoint using the Contract property. Then call the Behaviors property to obtain the KeyedByTypeCollection<TItem> of the IContractBehavior objects associated with the endpoint.
Applies to
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기