ReplicaMetadata.GetLocalVersions Method
When overridden in a derived class, gets a batch of changes that contains the versions of items and change units that are stored in this replica. These items and change units correspond to the items and change units referred to in a batch of changes that is sent from some other provider.
Namespace: Microsoft.Synchronization.MetadataStorage
Assembly: Microsoft.Synchronization.MetadataStorage (in Microsoft.Synchronization.MetadataStorage.dll)
Syntax
'Declaration
Public MustOverride Function GetLocalVersions ( _
sourceChanges As ChangeBatch _
) As IEnumerable(Of ItemChange)
'Usage
Dim instance As ReplicaMetadata
Dim sourceChanges As ChangeBatch
Dim returnValue As IEnumerable(Of ItemChange)
returnValue = instance.GetLocalVersions(sourceChanges)
public abstract IEnumerable<ItemChange> GetLocalVersions(
ChangeBatch sourceChanges
)
public:
virtual IEnumerable<ItemChange^>^ GetLocalVersions(
ChangeBatch^ sourceChanges
) abstract
abstract GetLocalVersions :
sourceChanges:ChangeBatch -> IEnumerable<ItemChange>
public abstract function GetLocalVersions(
sourceChanges : ChangeBatch
) : IEnumerable<ItemChange>
Parameters
- sourceChanges
Type: Microsoft.Synchronization.ChangeBatch
The batch of changes sent from another provider that is about to be applied to the item store that is associated with this replica.
Return Value
Type: System.Collections.Generic.IEnumerable<ItemChange>
A batch of changes that contains the versions of items and change units that are stored in this replica that correspond to the items and change units referred to in a batch of changes that is sent from some other provider.
Exceptions
Exception | Condition |
---|---|
ObjectDisposedException | The object has been disposed or was not initialized correctly. |
ArgumentNullException | sourceChanges is a null reference (Nothing in Visual Basic). |
Remarks
This method helps a synchronization provider implement its ProcessChangeBatch method.
Change appliers use the versions in the batch of changes that are returned from this method for conflict detection.
Notes to Implementers
The change batch that is returned from this method must contain one entry for every entry in sourceChanges, including change unit entries. If an item exists in the item store, its entry must contain its version information for this replica. If an item does not exist, its version must be set to SyncVersion.UnknownVersion, and its ItemChange.ChangeKind property must be set to UnknownItem.
Examples
The following example implements KnowledgeSyncProvider.ProcessChangeBatch by using GetLocalVersions to get the destination versions of source changes, and passing the result to NotifyingChangeApplier.ApplyChanges:
public override void ProcessChangeBatch(ConflictResolutionPolicy resolutionPolicy, ChangeBatch sourceChanges, object changeDataRetriever, SyncCallbacks syncCallbacks, SyncSessionStatistics sessionStatistics)
{
// Use the metadata storage service to get the local versions of changes received from the source provider.
IEnumerable<ItemChange> localVersions = _ContactStore.ContactReplicaMetadata.GetLocalVersions(sourceChanges);
// Use a NotifyingChangeApplier object to process the changes. Note that this object is passed as the INotifyingChangeApplierTarget
// object that will be called to apply changes to the item store.
NotifyingChangeApplier changeApplier = new NotifyingChangeApplier(ContactStore.ContactIdFormatGroup);
changeApplier.ApplyChanges(resolutionPolicy, sourceChanges, (IChangeDataRetriever)changeDataRetriever,
localVersions, _ContactStore.ContactReplicaMetadata.GetKnowledge(),
_ContactStore.ContactReplicaMetadata.GetForgottenKnowledge(), this, _sessionContext, syncCallbacks);
}