語言

BindingElement.GetProperty<T>(BindingContext) 方法

定義

當在派生類別中覆寫時,會回傳一個類型物件,若存在,則是從綁定堆疊中相應層請求的。

public:
generic <typename T>
 where T : class abstract T GetProperty(System::ServiceModel::Channels::BindingContext ^ context);
public abstract T GetProperty<T>(System.ServiceModel.Channels.BindingContext context) where T : class;
abstract member GetProperty : System.ServiceModel.Channels.BindingContext -> 'T (requires 'T : null)
Public MustOverride Function GetProperty(Of T As Class) (context As BindingContext) As T

類型參數

T

方法查詢的類型物件。

參數

context
BindingContext

這是 BindingContext 為了綁定元素。

傳回

T

該類型物件 T 會被請求是否存在 null 。

範例

CustomBinding binding = new CustomBinding();
HttpTransportBindingElement element = new HttpTransportBindingElement();
BindingParameterCollection parameters = new BindingParameterCollection();
parameters.Add(new ServiceCredentials());
Uri baseAddress = new Uri("http://localhost:8000/ChannelApp");
String relAddress = "http://localhost:8000/ChannelApp/service";
BindingContext context = new BindingContext(binding, parameters, baseAddress, relAddress, ListenUriMode.Explicit);

ServiceCredentials serviceCredentials = element.GetProperty<ServiceCredentials>(context);

備註

利用此方法從綁定元素堆疊中擷取能力、需求與參數。 如果綁定元素支援回傳所請求的物件,它就會回傳該物件。 若不行,則會將呼叫委派給堆疊中的下一個綁定元素。 如果它到達堆疊底部且沒有任何綁定元素支援該請求物件,則該方法會回傳 null。

Note

如果你新增必須加密的訊息標頭,當被要求ChannelProtectionRequirements時,必須回傳ChannelProtectionRequirements包含此方法需求的實例。

適用於