다음을 통해 공유


KnowledgeSyncProvider.GetChangeBatch 메서드

파생 클래스에서 재정의되면 대상 공급자의 지정된 정보에 포함되지 않은 항목에 대한 항목 메타데이터를 포함하는 변경 내용 일괄 처리를 가져옵니다.

네임스페이스: Microsoft.Synchronization
어셈블리: microsoft.synchronization.dll의 Microsoft.Synchronization

구문

‘선언
Public MustOverride Function GetChangeBatch ( _
    batchSize As UInteger, _
    destinationKnowledge As SyncKnowledge, _
    <OutAttribute> ByRef changeDataRetriever As Object _
) As ChangeBatch
‘사용 방법
Dim instance As KnowledgeSyncProvider
Dim batchSize As UInteger
Dim destinationKnowledge As SyncKnowledge
Dim changeDataRetriever As Object
Dim returnValue As ChangeBatch

returnValue = instance.GetChangeBatch(batchSize, destinationKnowledge, changeDataRetriever)
public abstract ChangeBatch GetChangeBatch (
    uint batchSize,
    SyncKnowledge destinationKnowledge,
    out Object changeDataRetriever
)
public:
virtual ChangeBatch^ GetChangeBatch (
    unsigned int batchSize, 
    SyncKnowledge^ destinationKnowledge, 
    [OutAttribute] Object^% changeDataRetriever
) abstract
public abstract ChangeBatch GetChangeBatch (
    UInt32 batchSize, 
    SyncKnowledge destinationKnowledge, 
    /** @attribute OutAttribute() */ /** @ref */ Object changeDataRetriever
)
JScript does not support passing value-type arguments by reference.

매개 변수

  • batchSize
    일괄 변경 내용에 포함될 변경 내용 수입니다.
  • destinationKnowledge
    대상 공급자의 정보입니다. 이 정보를 변경 내용 열거에 사용할 수 있으려면 원본 정보에서 MapRemoteKnowledgeToLocal을 호출하여 매핑해야 합니다.
  • changeDataRetriever
    변경 내용 데이터를 검색하는 데 사용할 수 있는 개체를 반환합니다. IChangeDataRetriever 개체이거나 공급자 관련 개체일 수 있습니다.

반환 값

대상 공급자의 지정된 정보에 포함되지 않은 항목에 대한 항목 메타데이터를 포함하는 변경 내용 일괄 처리입니다. null 참조(Visual Basic에서는 Nothing)일 수 없습니다.

주의

여러 일괄 처리에서 동일한 변경 내용이 표시되지는 않습니다.

남아 있는 변경 내용 수가 batchSize에서 지정한 수보다 작으면 더 작은 일괄 변경 내용이 반환됩니다.

변경 내용이 남아 있지 않을 때 이 메서드를 호출하면 InvalidOperationException을 발생시킵니다.

구현자를 위한 정보: 이 일괄 처리 후에 더 이상 보낼 변경 내용이 없으면 IsLastBatch를 반환되는 일괄 변경 내용에 대해 true로 설정해야 합니다. 그렇지 않으면 Sync Framework가 GetChangeBatch를 다시 호출하여 다른 변경 내용 일괄 처리를 검색합니다.

예제

다음 예제에서는 메타데이터 저장소에서 일괄 변경 내용을 가져옵니다.

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;

    // Call the metadata store to get a batch of changes.
    return _itemStore.ContactReplicaMetadata.GetChangeBatch(batchSize, destinationKnowledge);
}

다음 예제에서는 이전 예제에서 호출되는 GetChangeBatch 메서드를 보여 줍니다. 이 예제에서는 ChangeBatch 개체를 만들고 정렬된 그룹을 시작합니다. 또한 항목이 대상 정보에 포함되어 있지 않은 경우 항목을 정렬된 그룹에 추가합니다.

public override ChangeBatch GetChangeBatch(uint batchSize, SyncKnowledge destinationKnowledge)
{
    // The destination knowledge must be converted to be compatible with the source replica
    // before it can be used.
    SyncKnowledge mappedDestKnowledge = _knowledge.MapRemoteKnowledgeToLocal(destinationKnowledge);

    // Create a new change batch, initialized by using the current knowledge of the source replica
    // and a new ForgottenKnowledge object.
    ChangeBatch changeBatch = new ChangeBatch(IdFormats, GetKnowledge(), new ForgottenKnowledge());

    // Start a group of changes in the change batch. The group is ordered by item ID.
    // _getChangeBatchCurrent is 0 the first time GetChangeBatch is called, and is used to track the
    // position in the metadata store for subsequent calls to GetChangeBatch.
    changeBatch.BeginOrderedGroup(_items.Values[_getChangeBatchCurrent].GlobalId);
    
    // itemsAdded is incremented each time a change is added to the change batch. When itemsAdded
    // is greater than the requested batch size, enumeration stops and the change batch is returned.
    int itemsAdded = 0;
    
    ItemMetadata itemMeta;

    // Enumerate items and add a change to the change batch if it is not contained in the 
    // destination knowledge.
    // _items is a SortedList that contains ItemMetadata objects that are ordered by item ID.
    for (; itemsAdded <= batchSize && _getChangeBatchCurrent < _items.Count; _getChangeBatchCurrent++)
    {
        itemMeta = _items.Values[_getChangeBatchCurrent];
        ChangeKind kind = (itemMeta.IsDeleted) ? ChangeKind.Deleted : ChangeKind.Update;
        ItemChange change = new ItemChange(IdFormats, ReplicaId, itemMeta.GlobalId, kind, itemMeta.CreationVersion, 
            itemMeta.ChangeVersion);

        // If the change is not contained in the destination knowledge, add it to the change batch.
        if (!mappedDestKnowledge.Contains(change))
        {
            changeBatch.AddChange(change);
            itemsAdded++;
        }
    }

    // End the group of changes in the change batch. Pass the current source knowledge.
    changeBatch.EndOrderedGroup(_items.Values[_getChangeBatchCurrent - 1].GlobalId, _knowledge);

    // When all items in the metadata store have been enumerated, set this batch as the
    // last batch.
    if (_getChangeBatchCurrent == _items.Count)
    {
        changeBatch.SetLastBatch();
    }

    return changeBatch;
}

참고 항목

참조

KnowledgeSyncProvider 클래스
KnowledgeSyncProvider 멤버
Microsoft.Synchronization 네임스페이스