IMessageFilterTable<TFilterData> IMessageFilterTable<TFilterData> IMessageFilterTable<TFilterData> IMessageFilterTable<TFilterData> Interface

定義

interface,它會定義篩選資料表必須實作的合約,以便透過衍生自一或多個篩選條件的查詢準則來檢查訊息。An interface that defines the contract that a filter table must implement to inspect messages with query criteria derived from one or more filters.

generic <typename TFilterData>
public interface class IMessageFilterTable : System::Collections::Generic::ICollection<System::Collections::Generic::KeyValuePair<System::ServiceModel::Dispatcher::MessageFilter ^, TFilterData>>, System::Collections::Generic::IDictionary<System::ServiceModel::Dispatcher::MessageFilter ^, TFilterData>, System::Collections::Generic::IEnumerable<System::Collections::Generic::KeyValuePair<System::ServiceModel::Dispatcher::MessageFilter ^, TFilterData>>
public interface IMessageFilterTable<TFilterData> : System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<System.ServiceModel.Dispatcher.MessageFilter,TFilterData>>, System.Collections.Generic.IDictionary<System.ServiceModel.Dispatcher.MessageFilter,TFilterData>, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.ServiceModel.Dispatcher.MessageFilter,TFilterData>>
type IMessageFilterTable<'FilterData> = interface
    interface IDictionary<MessageFilter, 'FilterData>
    interface ICollection<KeyValuePair<MessageFilter, 'FilterData>>
    interface seq<KeyValuePair<MessageFilter, 'FilterData>>
    interface IEnumerable
Public Interface IMessageFilterTable(Of TFilterData)
Implements ICollection(Of KeyValuePair(Of MessageFilter, TFilterData)), IDictionary(Of MessageFilter, TFilterData), IEnumerable(Of KeyValuePair(Of MessageFilter, TFilterData))

類型參數

TFilterData

與資料表中每個篩選條件相關聯之資料的類型。The type of data associated with each filter in the table.

衍生
實作

備註

篩選資料表是篩選引擎的核心元件。The filter table is a core component of the filter engine. 篩選引擎在 Windows Communication Foundation (WCF) 的主要用途是尋找所有與訊息相符的篩選符合訊息的應用程式邏輯。The primary use of the filter engine in Windows Communication Foundation (WCF) is to match application logic to messages by finding all the filters that match a message.

比起逐一比對每個篩選條件和單一訊息,篩選資料表可更有效率地比對多重篩選條件和單一訊息。A filter table allows multiple filters to be matched against a single message more efficiently than they can be matched separately. 篩選資料表會使篩選資料與篩選條件產生關聯。A filter table associates filter data with filters. 資料表是索引鍵值組的集合,其中索引鍵為 MessageFilter,而值為相關聯的篩選資料。The table is a collection of key-value pairs, where the key is the MessageFilter, and the value is the associated filter data. 篩選資料可以是指定於泛型參數中之型別的任何資料,而且可以用來指定訊息與資料表中的篩選條件相符時所要採取的動作。Filter data can be any data of the type specified in the generic parameter and can be used to specify what actions to take if a message is matched by a filter in the table.

篩選資料表項目可透過 IDictionary<TKey,TValue> 所繼承的 IMessageFilterTable<TFilterData> 功能來加以存取。Filter table entries can be accessed using the IDictionary<TKey,TValue> functionality that IMessageFilterTable<TFilterData> inherits.

請注意,只能將篩選條件執行個體加入至指定的 IMessageFilterTable<TFilterData> 一次。Note that a filter instance can only be added to a given IMessageFilterTable<TFilterData> once. 若要將此篩選條件的多個執行個體加入至同一個篩選資料表,請使用篩選條件建構函式 (Constructor) 來建立額外的執行個體。To add multiple instances of this filter to the same filter table, use a filter constructor to create additional instances.

當訊息符合篩選條件的查詢準則時,即表示篩選條件與訊息相符。A filter matches a message when the message satisfies the query criteria of the filter. 有四種多載的比對方法。There are four overloaded matching methods. 傳回的資料不是篩選資料就是 MessageFilter 物件本身。The data returned is either the filter data or the MessageFilter objects themselves. 不論是允許多個符合項目或是只能有一個符合項目,都會傳回這個資料。This data is returned whether multiple matches are allowed or only a single match. 下表會針對每個多載顯示這份資訊。The following table shows this information for each overload.

方法名稱Method Name 符合Matches 傳回的資料Data Returned
GetMatchingValue SingleSingle FilterData
GetMatchingFilter SingleSingle MessageFilter
GetMatchingValues 多頁Multiple FilterData
GetMatchingFilters 多頁Multiple MessageFilter 物件MessageFilter objects

每個方法都包含有兩個多載。Each method contains two overloads. 這兩個多載之間的差異,在於一個多載會接受 Message 參數但是不允許檢查本文的內容,另外一個多載會接受 MessageBuffer 參數並且可以檢查訊息的任何部分。The difference between the two overloads is that one takes a Message parameter and is not permitted to examine the contents of the body; the other takes a MessageBuffer parameter and can examine any part of the message. 如果您以訊息參數呼叫方法,而且篩選資料表包含了檢查訊息本文內容的篩選條件,就會擲回例外狀況。If you call a method with the message parameter, and the filter table contains a filter that examines the content of the message body, an exception is thrown. 如果您不確定資料表中的篩選條件,請呼叫可接受訊息緩衝區的多載。If you are unsure about the filters in a table, call the overload that takes a message buffer.

訊息標頭會自動獲得緩衝,並且可以由篩選條件進行檢查,而不被取用。Message headers are automatically buffered and can be inspected by a filter without being consumed. 但若本文要由篩選條件檢查,整份訊息就必須加以緩衝,因為未緩衝的訊息本文將被查詢取用,因而導致其內容損毀。But if the body is to be inspected by a filter, then the entire message must be buffered because an unbuffered message body is consumed by a query and its contents destroyed.

下列類別會實作 IMessageFilterTable<TFilterData>The following classes implement IMessageFilterTable<TFilterData>:

方法

Add(T) Add(T) Add(T) Add(T)

將項目加入至 ICollection<T>Adds an item to the ICollection<T>.

(Inherited from ICollection<T>)
Add(TKey, TValue) Add(TKey, TValue) Add(TKey, TValue) Add(TKey, TValue)

將具有提供索引鍵和值的元素加入至 IDictionary<TKey,TValue>Adds an element with the provided key and value to the IDictionary<TKey,TValue>.

(Inherited from IDictionary<TKey,TValue>)
Clear() Clear() Clear() Clear()

ICollection<T> 中移除所有項目。Removes all items from the ICollection<T>.

(Inherited from ICollection<T>)
Contains(T) Contains(T) Contains(T) Contains(T)

判斷 ICollection<T> 是否包含特定值。Determines whether the ICollection<T> contains a specific value.

(Inherited from ICollection<T>)
ContainsKey(TKey) ContainsKey(TKey) ContainsKey(TKey) ContainsKey(TKey)

判斷 IDictionary<TKey,TValue> 是否包含具有指定之索引鍵的項目。Determines whether the IDictionary<TKey,TValue> contains an element with the specified key.

(Inherited from IDictionary<TKey,TValue>)
CopyTo(T[], Int32) CopyTo(T[], Int32) CopyTo(T[], Int32) CopyTo(T[], Int32)

從特定的 ICollection<T> 索引開始,將 Array 的項目複製到 ArrayCopies the elements of the ICollection<T> to an Array, starting at a particular Array index.

(Inherited from ICollection<T>)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

傳回逐一查看集合的列舉值。Returns an enumerator that iterates through a collection.

(Inherited from IEnumerable)
GetMatchingFilter(Message, MessageFilter) GetMatchingFilter(Message, MessageFilter) GetMatchingFilter(Message, MessageFilter) GetMatchingFilter(Message, MessageFilter)

傳回值,這個值會表示指定的訊息是否剛好只符合資料表中單一篩選條件的比對準則,並且傳回 out 參數中的該篩選條件。Returns a value that indicates whether the match criterion of exactly one filter in the table is satisfied by the specified message, and returns that filter in an out parameter.

GetMatchingFilter(MessageBuffer, MessageFilter) GetMatchingFilter(MessageBuffer, MessageFilter) GetMatchingFilter(MessageBuffer, MessageFilter) GetMatchingFilter(MessageBuffer, MessageFilter)

傳回值,這個值會指出指定的訊息或是緩衝的訊息是否只符合資料表中單一篩選條件的比對準則,並且傳回在 out 參數中的篩選條件。Returns a value that indicates whether the match criterion of exactly one filter in the table is satisfied by the specified message or buffered message, and returns that filter in an out parameter.

GetMatchingFilters(Message, ICollection<MessageFilter>) GetMatchingFilters(Message, ICollection<MessageFilter>) GetMatchingFilters(Message, ICollection<MessageFilter>) GetMatchingFilters(Message, ICollection<MessageFilter>)

傳回值,這個值會指出指定的訊息或是緩衝的訊息是否符合資料表中之篩選條件的比對準則,並且將相符的篩選條件新增至集合。Returns a value that indicates whether the match criterion of a filter in the table is satisfied by the specified message, and adds the matching filters to a collection.

GetMatchingFilters(MessageBuffer, ICollection<MessageFilter>) GetMatchingFilters(MessageBuffer, ICollection<MessageFilter>) GetMatchingFilters(MessageBuffer, ICollection<MessageFilter>) GetMatchingFilters(MessageBuffer, ICollection<MessageFilter>)

傳回值,這個值會指出緩衝的訊息是否符合資料表中之篩選條件的比對準則,並且將相符的篩選條件新增至集合。Returns a value that indicates whether the match criterion of a filter in the table is satisfied by the specified buffered message, and adds the matching filters to a collection.

GetMatchingValue(Message, TFilterData) GetMatchingValue(Message, TFilterData) GetMatchingValue(Message, TFilterData) GetMatchingValue(Message, TFilterData)

傳回值,這個值會指出指定的訊息是否只符合資料表中之一個篩選條件的比對準則,並且將相符的篩選資料新增至集合。Returns a value that indicates whether the match criterion of exactly one filter in the table is satisfied by the specified message, and adds the matching filter data to a collection.

GetMatchingValue(MessageBuffer, TFilterData) GetMatchingValue(MessageBuffer, TFilterData) GetMatchingValue(MessageBuffer, TFilterData) GetMatchingValue(MessageBuffer, TFilterData)

傳回值,這個值會指出指定的緩衝訊息是否只符合資料表中單一篩選條件的比對準則,並且將相符的篩選資料新增至集合。Returns a value that indicates whether the match criterion of exactly one filter in the table is satisfied by the specified buffered message, and adds the matching filter data to a collection.

GetMatchingValues(Message, ICollection<TFilterData>) GetMatchingValues(Message, ICollection<TFilterData>) GetMatchingValues(Message, ICollection<TFilterData>) GetMatchingValues(Message, ICollection<TFilterData>)

傳回值,這個值會指出指定的訊息是否符合資料表中至少一個篩選條件的比對準則,並且將相符篩選條件的 FilterData 加入至集合。Returns a value that indicates whether the match criterion of at least one filter in the table is satisfied by the specified message, and adds the FilterData of the matching filters to a collection.

GetMatchingValues(MessageBuffer, ICollection<TFilterData>) GetMatchingValues(MessageBuffer, ICollection<TFilterData>) GetMatchingValues(MessageBuffer, ICollection<TFilterData>) GetMatchingValues(MessageBuffer, ICollection<TFilterData>)

傳回值,這個值會指出指定的緩衝訊息是否符合資料表中至少一個篩選條件的比對準則,並且將相符篩選條件的 FilterData 加入至集合。Returns a value that indicates whether the match criterion of at least one filter in the table is satisfied by the specified buffered message, and adds the FilterData of the matching filters to a collection.

Remove(TKey) Remove(TKey) Remove(TKey) Remove(TKey)

IDictionary<TKey,TValue> 中移除具有指定之索引鍵的項目。Removes the element with the specified key from the IDictionary<TKey,TValue>.

(Inherited from IDictionary<TKey,TValue>)
TryGetValue(TKey, TValue) TryGetValue(TKey, TValue) TryGetValue(TKey, TValue) TryGetValue(TKey, TValue)

取得與指定索引鍵關聯的值。Gets the value associated with the specified key.

(Inherited from IDictionary<TKey,TValue>)

屬性

Count Count Count Count

取得 ICollection<T> 中所包含的項目數。Gets the number of elements contained in the ICollection<T>.

(Inherited from ICollection<T>)
IsReadOnly IsReadOnly IsReadOnly IsReadOnly

取得值,指出 ICollection<T> 是否唯讀。Gets a value indicating whether the ICollection<T> is read-only.

(Inherited from ICollection<T>)
Item[TKey] Item[TKey] Item[TKey] Item[TKey]

取得或設定具有指定索引鍵的項目。Gets or sets the element with the specified key.

(Inherited from IDictionary<TKey,TValue>)
Keys Keys Keys Keys

取得 ICollection<T>,包含 IDictionary<TKey,TValue> 的索引鍵。Gets an ICollection<T> containing the keys of the IDictionary<TKey,TValue>.

(Inherited from IDictionary<TKey,TValue>)
Values Values Values Values

取得 ICollection<T>,包含 IDictionary<TKey,TValue> 中的值。Gets an ICollection<T> containing the values in the IDictionary<TKey,TValue>.

(Inherited from IDictionary<TKey,TValue>)

Extension Methods

CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>) CopyToDataTable<T>(IEnumerable<T>)

傳回DataTable,其中包含副本DataRow物件,指定輸入IEnumerable<T>物件其中泛型參數TDataRowReturns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

複本DataRow至指定的物件DataTable,根據輸入IEnumerable<T>物件其中泛型參數TDataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler) CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

複本DataRow至指定的物件DataTable,根據輸入IEnumerable<T>物件其中泛型參數TDataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

篩選的項目IEnumerable根據指定的型別。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

將轉換IEnumerableIQueryableConverts an IEnumerable to an IQueryable.

Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>) Ancestors<T>(IEnumerable<T>)

傳回包含來源集合中每個節點祖系的項目集合。Returns a collection of elements that contains the ancestors of every node in the source collection.

Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName) Ancestors<T>(IEnumerable<T>, XName)

傳回包含來源集合中每個節點祖系的已篩選項目集合。Returns a filtered collection of elements that contains the ancestors of every node in the source collection. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>) DescendantNodes<T>(IEnumerable<T>)

傳回來源集合中每個文件和項目之子代節點的集合。Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>) Descendants<T>(IEnumerable<T>)

傳回包含來源集合中每個項目和文件之子代項目的項目集合。Returns a collection of elements that contains the descendant elements of every element and document in the source collection.

Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName) Descendants<T>(IEnumerable<T>, XName)

傳回已篩選的項目集合,其中包含來源集合中每個項目和文件的子代項目。Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>) Elements<T>(IEnumerable<T>)

傳回來源集合中每個項目和文件的子項目集合。Returns a collection of the child elements of every element and document in the source collection.

Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName) Elements<T>(IEnumerable<T>, XName)

傳回來源集合中每個項目和文件的已篩選子項目集合。Returns a filtered collection of the child elements of every element and document in the source collection. 集合中只會包含具有相符之 XName 的項目。Only elements that have a matching XName are included in the collection.

InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>) InDocumentOrder<T>(IEnumerable<T>)

傳回包含來源集合中所有節點的節點集合,依據文件順序來排序。Returns a collection of nodes that contains all nodes in the source collection, sorted in document order.

Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>) Nodes<T>(IEnumerable<T>)

傳回來源集合中每個文件和項目的子節點集合。Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>) Remove<T>(IEnumerable<T>)

在來源集合中,從每一個節點的父節點移除這些節點。Removes every node in the source collection from its parent node.

適用於

執行緒安全性

對於比對作業,篩選資料表是安全執行緒 (Thread-Safe),但對修改作業而言則不是安全執行緒。Filter tables are thread-safe with respect to matching operations, but are not thread-safe with respect to modification. 存取篩選資料表的執行緒必須由 ReaderWriterLock 或相似的鎖定語意同步處理。Threads that access a filter table should be synchronized by the ReaderWriterLock or similar locking semantic. 這種鎖定允許多次讀取篩選資料表來進行同步執行 (例如,進行比對作業時),但是如果要寫入篩選資料表 (例如,加入篩選條件),執行緒就必須等候獨佔鎖定。This lock allows multiple reads of a filter table (for example, a match operation) to run simultaneously, but in order to write to a filter table (for example, adding a filter), a thread must wait for an exclusive lock.

所有的編譯都會在篩選條件加入至資料表時完成。All compilation is done when filters are added to the table. 如果您預先建立了篩選資料表,但從未編輯它,在進行比對時就不需要鎖定。If you create a filter table in advance, and never edit it, locking is not necessary during a match.