ChannelBase.GetProperty<T> 方法
定义
从通道堆栈的适当层,返回所请求的类型化对象(如果存在)。Returns the typed object requested, if present, from the appropriate layer in the channel stack.
public:
generic <typename T>
where T : class virtual T GetProperty();
public virtual T GetProperty<T> () where T : class;
abstract member GetProperty : unit -> 'T (requires 'T : null)
override this.GetProperty : unit -> 'T (requires 'T : null)
Public Overridable Function GetProperty(Of T As Class) () As T
类型参数
- T
方法正在查询的类型化对象。The typed object for which the method is querying.
返回
- T
如果存在,则返回所请求的类型化对象 T,如果不存在,则返回 null。The 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. 如果到达堆栈底部仍然没有通道层支持所请求的对象,则该方法返回 null。If it gets to the bottom of the stack and no channel layer supported the requested object, then the method returns null.
此外,任何时候要实现通道,都必须确保重写 GetProperty。You must also make sure to override GetProperty whenever you implement a channel. GetProperty 是一种通过通道堆栈传达信息的绝佳方式,无需知道哪些通道低于你,或者上述哪些通道可执行查询。GetProperty is an excellent way to communicate information along the channel stack without having to know what channels are below you, or what channels above you may perform queries. 定义可从中查询可用信息的接口。Define interfaces that can be queried for available information. 如果不能识别 GetProperty 的类型参数,则委托给堆栈中的下一个通道,如果要在堆栈底部创建一个新的传输通道,则返回 null。Whenever you do not recognize the type argument for GetProperty, delegate down to the next channel in the stack or return null if you are creating a new transport channel at the bottom of the stack.