IChannelFactory.GetProperty<T> 方法

定义

从通道堆栈的适当层返回所请求的类型化对象(如果存在)。Returns a typed object requested, if present, from the appropriate layer in the channel stack.

public:
generic <typename T>
 where T : class T GetProperty();
public T GetProperty<T> () where T : class;
abstract member GetProperty : unit -> 'T (requires 'T : null)
Public Function GetProperty(Of T As Class) () As T

类型参数

T

方法正在查询的类型化对象。The typed object for which the method is querying.

返回

T

如果存在,则返回所请求的类型化对象 T,如果不存在,则返回 nullThe typed object T requested, if it is present, or null if it is not.

注解

使用此方法可请求从通道堆栈的适当层返回一个类型化对象,如用于设置属性或获取状态的接口。Use this to request a typed object such as an interface for setting properties or getting status from the appropriate layer in the channel stack. 如果某个层支持返回所请求的对象,则该层会返回对象。If a layer supports returning the requested object, it returns it. 如果不支持,则该层会将调用委托给堆栈中的下一层。If not, it delegates the call down to the next layer in the stack. 如果到达堆栈底部仍然没有通道层支持所请求的对象,则该方法返回 nullIf it gets to the bottom of the stack and no channel layer supported the requested object, then the method returns null.

任何时候要实现通道工厂,都必须实现 GetPropertyYou must implement GetProperty whenever you implement a channel factory. GetProperty 是一种通过通道工厂堆栈传达信息的绝佳方式,无需知道哪些通道工厂位于你的下方,或者你对哪些通道工厂感兴趣来执行查询。GetProperty is an excellent way to communicate information along the channel factory stack without having to know what channel factories are below you, or what channel factories above you are interested in performing queries. 定义一些接口,供人们查询您所拥有任何相关信息。Define interfaces for people to query on for any interesting information you have. 如果不能识别 GetProperty 的类型参数,则委托给堆栈中的下一个通道工厂,如果要在堆栈底部创建一个新传输通道,则返回 nullWhenever you do not recognize the type argument for GetProperty, delegate down to the next channel factory in the stack or return null if you are creating a new transport channel at the bottom of the stack.

适用于