MessageEncodingBindingElement.GetProperty<T>(BindingContext) 方法

定義

從通道堆疊的適當層次中,傳回要求的型別物件 (如果有的話)。

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

類型參數

T

此方法正在查詢的型別物件。

參數

context
BindingContext

目前繫結項目的 BindingContext

傳回

T

要求的型別物件 T (如果存在的話),如果不存在則為 null

例外狀況

contextnull

範例

下列程式碼說明如何實作 GetProperty<T>(BindingContext) 方法:

public override T GetProperty<T>(BindingContext context)
{
    if (typeof(T) == typeof(XmlDictionaryReaderQuotas))
    {
        return (T)(object)this.readerQuotas;
    }
    else
    {
        return base.GetProperty<T>(context);
    }
}

備註

使用此方法可要求型別物件,例如,用來從通道堆疊中的適當層次接收屬性或取得狀態的介面。 如果某個層次支援傳回要求的物件,它就會傳回物件。 如果不是,則會將呼叫向下委派到堆疊中的下一層。 如果到達堆疊的底部,而且沒有任何通道層支援要求的物件,則該方法會傳回 null

適用於