FilterChange Class

Represents information about a change that causes an item to move in or out of a filter.

System.Object
  Microsoft.Synchronization.FilterChange

Namespace:  Microsoft.Synchronization
Assembly:  Microsoft.Synchronization (in Microsoft.Synchronization.dll)

'Declaration
Public Class FilterChange
'Usage
Dim instance As FilterChange

The FilterChange type exposes the following members.

  NameDescription
Public methodFilterChangeInitializes a new instance of the FilterChange class that contains the specified value that indicates whether the item is in the filter, and the version of the change that caused the move.
Top

  NameDescription
Public propertyIsMoveInGets a value that indicates whether the item is in the filter.
Public propertyMoveVersionGets the version of the change that caused the item to move in relation to the filter.
Top

  NameDescription
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
Top

A change can cause an item to move into or out of a filter. For example, items contain a state field, and a filter excludes any item with its state field equal to "Washington". When an item with state equal to "Washington" changes so that state equals "Oregon", the item moves into the filter.

The properties of this object can be interpreted according to the following table.

Value ofIsMoveIn

Value ofMoveVersion

Meaning

true

The creation version of the item.

The item has been in the filter since it was created.

true

A version other than the creation version of the item.

The item moved into the filter when the change with version of MoveVersion was made.

false

Set to 0.

The item has not been in the filter since filter tracking began.

false

A version other than 0.

The item moved out of the filter when the change with version of MoveVersion was made.

The following example adds filter change information to an ItemChange object when the move version for the item in relation to the filter is not contained in the destination knowledge.

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);
        }
    }
}


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show: