XPathMessageFilterTable<TFilterData>.TryGetValue(MessageFilter, TFilterData) 方法

定义

检查筛选器是否存储在筛选器表中。Checks whether a filter is stored in the filter table.

public:
 virtual bool TryGetValue(System::ServiceModel::Dispatcher::MessageFilter ^ filter, [Runtime::InteropServices::Out] TFilterData % data);
public bool TryGetValue (System.ServiceModel.Dispatcher.MessageFilter filter, out TFilterData data);
abstract member TryGetValue : System.ServiceModel.Dispatcher.MessageFilter * 'FilterData -> bool
override this.TryGetValue : System.ServiceModel.Dispatcher.MessageFilter * 'FilterData -> bool
Public Function TryGetValue (filter As MessageFilter, ByRef data As TFilterData) As Boolean

参数

filter
MessageFilter

用于检索数据的键。A key to retrieve the data.

data
TFilterData

当此方法返回 data 时,则返回与 filter 关联的 true;否则,将返回 data 参数的类型的默认值。The data associated with the filter when this method returns true; otherwise, the default value for the type of the data parameter.

返回

如果筛选器表中存在 filter,则为 true;否则为 falsetrue if the filter is present in the filter table; false otherwise.

注解

在检查筛选器是否在筛选器表中时,此方法是一种有效的方法,因为如果筛选器不存在,则此方法会返回 false,而不会引发异常。This method is an efficient way to check whether a filter is in the filter table because when the filter is not present it returns false instead of throwing an exception. 如果尝试使用筛选器的 Item 属性(C# 中为索引器)从表中检索筛选器,并且此筛选器在表中不存在,则会引发异常。If you try to retrieve the filter from the table using its Item property (the indexer in C#) and it is not there, an exception is thrown.

适用于