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.
Assembly: Microsoft.Synchronization.MetadataStorage (in Microsoft.Synchronization.MetadataStorage.dll)
public abstract IEnumerable<ItemChange> GetLocalVersions( ChangeBatch sourceChanges )
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.
| Exception | Condition |
|---|---|
| ObjectDisposedException | The object has been disposed or was not initialized correctly. |
| ArgumentNullException | sourceChanges is a null. |
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 ImplementersThe 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.
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); }