共用方式為


ItemChange.AddFilterChange 方法

加入表示這項變更是否會造成項目移入或移出指定之篩選的資訊。

命名空間: Microsoft.Synchronization
組件: Microsoft.Synchronization (在 microsoft.synchronization.dll)

語法

'宣告
Public Sub AddFilterChange ( _
    filterKey As UInteger, _
    filterChange As FilterChange _
)
'用途
Dim instance As ItemChange
Dim filterKey As UInteger
Dim filterChange As FilterChange

instance.AddFilterChange(filterKey, filterChange)
public void AddFilterChange (
    uint filterKey,
    FilterChange filterChange
)
public:
void AddFilterChange (
    unsigned int filterKey, 
    FilterChange^ filterChange
)
public void AddFilterChange (
    UInt32 filterKey, 
    FilterChange filterChange
)
public function AddFilterChange (
    filterKey : uint, 
    filterChange : FilterChange
)

參數

  • filterKey
    項目移入或移出之篩選的機碼。
  • filterChange
    相對於 filterKey 所指定之篩選的變更相關資訊。

例外

例外狀況型別 條件

ArgumentNullException

必要的參數為 null 參考 (在 Visual Basic 中為 Nothing)。

ArgumentOutOfRangeException

filterKey 是無效的值。

SyncInvalidOperationException

filterKey 的篩選變更資訊已經存在。

備註

變更可能會導致項目移入或移出篩選。例如,項目會包含 state 欄位,而且篩選會排除其 state 欄位等於 "Washington" 的任何項目。當某個 state 等於 "Washington" 的項目變更,讓 state 等於 "Oregon" 時,此項目就會移入篩選。

範例

下列範例會在項目相對於篩選的移動版本未包含在目的地知識中時,將篩選變更資訊加入到 ItemChange 物件。

Public Sub AddFilterChanges(ByVal filterKeyMap As FilterKeyMap, ByVal itemMeta As ItemMetadata, ByVal destKnowledge As SyncKnowledge, ByVal itemChange As ItemChange)
    For filterKey As Integer = 0 To filterKeyMap.Count - 1
        ' Find the filter in the list of all filters tracked by this replica.
        Dim iFilter As Integer = 0
        While iFilter < _trackedFilters.Count
            If filterKeyMap(filterKey).IsIdentical(_trackedFilters(iFilter)) Then
                Exit While
            End If
            iFilter += 1
        End While

        ' Get the filter information for the item and add it to the ItemChange object.
        Dim moveVersion As SyncVersion = GetMoveVersion(itemMeta, iFilter)

        ' Only return a filter change if the destination knowledge does not contain the version of the 
        ' last move that occurred in relation to the specified filter.
        Dim filterChange As FilterChange = Nothing
        If Not destKnowledge.Contains(ContactReplicaMetadata.ReplicaId, itemMeta.GlobalId, moveVersion) Then
            filterChange = New FilterChange(GetIsInFilter(itemMeta, iFilter), moveVersion)
            itemChange.AddFilterChange(CUInt(filterKey), filterChange)
        End If
    Next
End Sub
public void AddFilterChanges(FilterKeyMap filterKeyMap, ItemMetadata itemMeta, SyncKnowledge destKnowledge,
    ItemChange itemChange)
{
    for (int filterKey = 0; filterKey < filterKeyMap.Count; filterKey++)
    {
        // Find the filter in the list of all filters tracked by this replica.
        int iFilter = 0;
        for (; iFilter < _trackedFilters.Count; iFilter++)
        {
            if (filterKeyMap[filterKey].IsIdentical(_trackedFilters[iFilter]))
            {
                break;
            }
        }

        // Get the filter information for the item and add it to the ItemChange object.
        SyncVersion moveVersion = GetMoveVersion(itemMeta, iFilter);

        // Only return a filter change if the destination knowledge does not contain the version of the 
        // last move that occurred in relation to the specified filter.
        FilterChange filterChange = null;
        if (!destKnowledge.Contains(ContactReplicaMetadata.ReplicaId, itemMeta.GlobalId, moveVersion))
        {
            filterChange = new FilterChange(GetIsInFilter(itemMeta, iFilter), moveVersion);
            itemChange.AddFilterChange((uint)filterKey, filterChange);
        }
    }
}

請參閱

參考

ItemChange 類別
ItemChange 成員
Microsoft.Synchronization 命名空間