Share via


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 命名空间