ChangeUnitListFilterInfo Constructor (SyncIdFormatGroup, ICollection<SyncId>, Boolean)

Initializes a new instance of the ChangeUnitListFilterInfo class that contains the specified ID format schema, the collection of change unit IDs that indicate which change units are included by this filter, and a value that indicates whether the filter applies to all items in the scope.

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

public:
ChangeUnitListFilterInfo(
	SyncIdFormatGroup^ idFormats, 
	ICollection<SyncId^>^ changeUnitIds, 
	bool appliesToAllItems
)

Parameters

idFormats
Type: Microsoft.Synchronization::SyncIdFormatGroup
The ID format schema of the provider.
changeUnitIds
Type: System.Collections.Generic::ICollection<SyncId>
The collection of change unit IDs that indicate which change units are included by this filter.
appliesToAllItems
Type: System::Boolean
true when the filter applies to all items in the scope. Otherwise, false.

ExceptionCondition
ArgumentNullException

idFormats or changeUnitIds is a nullptr.

ArgumentException

changeUnitIds is empty.

The following example builds a list of change unit IDs to include in synchronization, and uses the list of change unit IDs to create a ChangeUnitListFilterInfo object. The ChangeUnitListFilterInfo object is passed to the GetFilteredChangeBatch method to retrieve a filtered change batch from the metadata storage service.

Public Sub SetContactFieldsToInclude(ByVal includedFields As Contact.ChangeUnitFields())
    ' Translate the array of fields to a list of IDs.
    _includedChangeUnits = New List(Of SyncId)(includedFields.Length)
    For iField As Integer = 0 To includedFields.Length - 1
        _includedChangeUnits.Add(New SyncId(CByte(includedFields(iField))))
    Next

    _isFiltered = True
End Sub


Public Overrides Function GetChangeBatch(ByVal batchSize As UInteger, ByVal destinationKnowledge As SyncKnowledge, ByRef changeDataRetriever As Object) As ChangeBatch
    ' Return this object as the IChangeDataRetriever object that is called to retrieve item data.
    changeDataRetriever = Me

    Dim retrievedBatch As ChangeBatch
    If _isFiltered Then
        ' Use the metadata storage service to get a filtered batch of changes.
        Dim filterInfo As New ChangeUnitListFilterInfo(IdFormats, _includedChangeUnits, True)
        retrievedBatch = _ContactStore.ContactReplicaMetadata.GetFilteredChangeBatch(batchSize, destinationKnowledge, filterInfo, Nothing)
    Else
        ' Use the metadata storage service to get a batch of changes.
        retrievedBatch = _ContactStore.ContactReplicaMetadata.GetChangeBatch(batchSize, destinationKnowledge)
    End If

    Return retrievedBatch
End Function


public void SetContactFieldsToInclude(Contact.ChangeUnitFields[] includedFields)
{
    // Translate the array of fields to a list of IDs.
    _includedChangeUnits = new List<SyncId>(includedFields.Length);
    for (int iField = 0; iField < includedFields.Length; iField++)
    {
        _includedChangeUnits.Add(new SyncId((byte)includedFields[iField]));
    }

    _isFiltered = true;
}


public override ChangeBatch GetChangeBatch(uint batchSize, SyncKnowledge destinationKnowledge, out object changeDataRetriever)
{
    // Return this object as the IChangeDataRetriever object that is called to retrieve item data.
    changeDataRetriever = this;

    ChangeBatch retrievedBatch;
    if (_isFiltered)
    {
        // Use the metadata storage service to get a filtered batch of changes.
        ChangeUnitListFilterInfo filterInfo = new ChangeUnitListFilterInfo(IdFormats, _includedChangeUnits, true);
        retrievedBatch = _ContactStore.ContactReplicaMetadata.GetFilteredChangeBatch(batchSize, destinationKnowledge,
            filterInfo, null);
    }
    else
    {
        // Use the metadata storage service to get a batch of changes.
        retrievedBatch = _ContactStore.ContactReplicaMetadata.GetChangeBatch(batchSize, destinationKnowledge);
    }

    return retrievedBatch;
}


Show: