MessageEncodingBindingElement.GetProperty<T>(BindingContext) 方法     
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
从通道堆栈的适当层,返回所请求的类型化对象(如果存在)。
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,如果不存在,则为 null。
例外
              context 为 null。
示例
下面的代码演示如何实现 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。