GetFilteredChangeBatch メソッド

派生クラスでオーバーライドされると、同期先プロバイダーからの指定したナレッジに含まれていない項目のうち、指定したフィルターによって受け入れられた項目に関する項目メタデータが含まれた変更バッチを取得します。

名前空間:  Microsoft.Synchronization.MetadataStorage
アセンブリ:  Microsoft.Synchronization.MetadataStorage (Microsoft.Synchronization.MetadataStorage.dll 内)

構文

'宣言
Public MustOverride Function GetFilteredChangeBatch ( _
    batchSize As UInteger, _
    destinationKnowledge As SyncKnowledge, _
    filterInfo As FilterInfo, _
    filterCallback As ReplicaMetadata..::..ItemFilterCallback _
) As ChangeBatch
'使用
Dim instance As ReplicaMetadata
Dim batchSize As UInteger
Dim destinationKnowledge As SyncKnowledge
Dim filterInfo As FilterInfo
Dim filterCallback As ReplicaMetadata..::..ItemFilterCallback
Dim returnValue As ChangeBatch

returnValue = instance.GetFilteredChangeBatch(batchSize, _
    destinationKnowledge, filterInfo, _
    filterCallback)
public abstract ChangeBatch GetFilteredChangeBatch(
    uint batchSize,
    SyncKnowledge destinationKnowledge,
    FilterInfo filterInfo,
    ReplicaMetadata..::..ItemFilterCallback filterCallback
)
public:
virtual ChangeBatch^ GetFilteredChangeBatch(
    unsigned int batchSize, 
    SyncKnowledge^ destinationKnowledge, 
    FilterInfo^ filterInfo, 
    ReplicaMetadata..::..ItemFilterCallback^ filterCallback
) abstract
abstract GetFilteredChangeBatch : 
        batchSize:uint32 * 
        destinationKnowledge:SyncKnowledge * 
        filterInfo:FilterInfo * 
        filterCallback:ReplicaMetadata..::..ItemFilterCallback -> ChangeBatch 
public abstract function GetFilteredChangeBatch(
    batchSize : uint, 
    destinationKnowledge : SyncKnowledge, 
    filterInfo : FilterInfo, 
    filterCallback : ReplicaMetadata..::..ItemFilterCallback
) : ChangeBatch

パラメーター

戻り値

型 : Microsoft.Synchronization. . :: . .ChangeBatch
同期先プロバイダーからの指定したナレッジに含まれていない項目のうち、指定したフィルターで受け入れられる項目の項目メタデータが含まれた変更バッチです。

例外

例外 条件
ObjectDisposedException

オブジェクトが破棄されているか、正しく初期化されていません。

ArgumentOutOfRangeException

batchSize が 0 です。

ArgumentNullException

destinationKnowledge が null Nothing nullptr unit NULL 参照 (Visual Basic では Nothing) であるか、filterInfo が null Nothing nullptr unit NULL 参照 (Visual Basic では Nothing) です。

説明

フィルターされた同期が指定されている場合、このメソッドを使用すると、同期プロバイダーは GetChangeBatch メソッドを実装できるようになります。

filterCallback デリゲートは、各項目がバッチに追加される前に呼び出されます。デリゲートが true を返す場合、項目はバッチに追加されます。それ以外の場合、項目はバッチに追加されません。

プロバイダーは、このメソッドを呼び出す前に、メタデータ ストア内のバージョンにローカルの変更 (削除など) がすべて反映されていることを確認する必要があります。これを行うには、メタデータを明示的にメンテナンスすることによって、項目を列挙し、そのメタデータを更新します。

SqlMetadataStore を使用することによって可能になるこのクラスの実装では、変更がグローバル ID の順で変更バッチに追加されます。

SqlMetadataStore を使用することによって可能になるこのクラスの実装では、送信する変更がなくなった場合に返される変更バッチで IsLastBatch が true に設定されます。

実装に関するメモ

グローバル ID 順を使用しており、範囲を使用できるプロバイダーをサポートするには、変更を列挙してから、変更バッチにグローバル ID 順で追加する必要があります。返された変更バッチ内の最初の変更によって新しい範囲が開始されます。

このバッチの後で送信する変更がもうない場合は、返される変更バッチで IsLastBatch を true に設定する必要があります。そうしないと、次の変更バッチを取得するために、Sync Framework によって GetChangeBatch()()()() が再度呼び出されます。

次の例では、ItemListFilterInfo オブジェクトを作成して ReplicaMetadata..::..ItemFilterCallback の実装と共に使用し、フィルターされた変更バッチを取得します。また、ReplicaMetadata..::..ItemFilterCallback の実装も含まれます。

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

    ' Use the metadata storage service to get a batch of changes.
    Dim retrievedBatch As ChangeBatch
    If _isFiltered Then
        ' If a filter is set, get a filtered change batch from the metadata storage service.
        ' The BirthdateFilterCallback method indicates whether an item passes the filter.
        Dim filterInfo As New ItemListFilterInfo(IdFormats)
        retrievedBatch = _ContactStore.ContactReplicaMetadata.GetFilteredChangeBatch(batchSize, destinationKnowledge, filterInfo, AddressOf BirthdateFilterCallback)
    Else
        retrievedBatch = _ContactStore.ContactReplicaMetadata.GetChangeBatch(batchSize, destinationKnowledge)
    End If

    Return retrievedBatch
End Function
Public Function BirthdateFilterCallback(ByVal itemMeta As ItemMetadata) As Boolean
    ' An item passes the filter only if its birthdate field is less than the maximum birthdate
    ' specified by the filter.
    Return (_ContactStore.ContactList(itemMeta.GlobalId).Birthdate < _maxBirthdateFilter)
End Function
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;

    // Use the metadata storage service to get a batch of changes.
    ChangeBatch retrievedBatch;
    if (_isFiltered)
    {
        // If a filter is set, get a filtered change batch from the metadata storage service.
        // The BirthdateFilterCallback method indicates whether an item passes the filter.
        ItemListFilterInfo filterInfo = new ItemListFilterInfo(IdFormats);
        retrievedBatch = _ContactStore.ContactReplicaMetadata.GetFilteredChangeBatch(batchSize, destinationKnowledge,
            filterInfo, BirthdateFilterCallback);
    }
    else
    {
        retrievedBatch = _ContactStore.ContactReplicaMetadata.GetChangeBatch(batchSize, destinationKnowledge);
    }

    return retrievedBatch;
}
public bool BirthdateFilterCallback(ItemMetadata itemMeta)
{
    // An item passes the filter only if its birthdate field is less than the maximum birthdate
    // specified by the filter.
    return (_ContactStore.ContactList[itemMeta.GlobalId].Birthdate < _maxBirthdateFilter);
}

参照

参照

ReplicaMetadataクラス

ReplicaMetadata メンバー

Microsoft.Synchronization.MetadataStorage 名前空間