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

注意

如果要加入必須加密的訊息標頭,您必須在要求 ChannelProtectionRequirements 時從這個方法傳回符合您要求的 ChannelProtectionRequirements 執行個體。

適用於