Implementing a Standard Custom Provider

In Microsoft Sync Framework, a synchronization provider is a software component that enables a replica to synchronize its data with other replicas. By using a synchronization session, a synchronization application connects a destination provider with a source provider to synchronize items that have changed on the source replica to the destination replica. A simple example of a synchronization provider is one that manages a folder in a file system. This provider can be connected with another provider that also manages a folder to synchronize the files in its folder with the files in the other provider's folder.

During synchronization, the destination provider provides its current knowledge, accepts a list of changes from the source, detects any conflicts between that list and its own items, perhaps filters the list of items, and applies changes to its data store. The source provider uses the destination replica's current knowledge to determine which changes are in the source replica that the destination replica does not know about, perhaps filters the list of changes, and sends the list of changes to the destination provider. Sync Framework provides components to handle many of these tasks on behalf of these providers.

Implementing a Synchronization Provider

A synchronization provider can be implemented by using managed or unmanaged code.

Security noteSecurity Note

Sync Framework treats synchronization providers as trusted code. Therefore, an application that invokes a synchronization provider must establish that the provider is trusted either by having explicit knowledge of the provider or by using some other mechanism, such as a digital signature.

Implementing a Synchronization Provider by Using Managed Code

The main task when you are developing a provider is to implement the KnowledgeSyncProvider abstract class (which inherits from the SyncProvider abstract class) and the IChangeDataRetriever and INotifyingChangeApplierTarget interfaces.

Before synchronization can begin, the provider must first make its implementation of SyncProvider available to the synchronization application by using whatever mechanism that the application requires.

During a typical synchronization, Sync Framework makes the following basic calls:

For more information about how to create a synchronization provider, see How to: Create a Managed Synchronization Provider.

Implementing a Synchronization Provider by Using Unmanaged Code

The main task when you are developing a provider is to implement the IKnowledgeSyncProvider, ISyncProvider, ISynchronousDataRetriever, and ISynchronousNotifyingChangeApplierTarget interfaces. Asynchronous versions of some of these interfaces also exist; see IAsynchronousDataRetriever Interface and IAsynchronousNotifyingChangeApplierTarget Interface.

Before synchronization can begin, the provider must first make its implementation of ISyncProvider available to the synchronization application by using whatever mechanism that the application requires.

During a typical synchronization, Sync Framework makes the following basic calls:

  • BeginSession is called on both providers. This informs a provider that it is joining a synchronization session.

  • GetSyncBatchParameters is called on the destination provider. The destination provider returns its knowledge and requested batch size.

  • GetChangeBatch is called on the source provider and passes the destination provider's knowledge. The source provider uses the destination provider's knowledge to detect changes and returns a batch of them. For more information, see Enumerating Changes.

  • ProcessChangeBatch is called on the destination provider and passes the list of changes from the source provider. The destination provider uses the Sync Framework change applier component to detect conflicts and apply changes. For more information, see Handling Conflicts and Applying Changes.

  • LoadChangeData is called on the source provider for each change in the batch. The source provider returns an interface to its data transfer mechanism.

  • SaveChange is called on the destination provider for each change in the batch. The destination provider uses the source's transfer mechanism to transfer the data that is associated with the change.

  • SaveKnowledge is called on the destination provider. The destination provider saves the knowledge that is passed in as its current knowledge.

  • EndSession is called on both providers. This informs a provider that it is leaving a synchronization session that it had previously joined.

For more information about how to create a synchronization provider, see How to: Create an Unmanaged Synchronization Provider.

See Also

Reference

IKnowledgeSyncProvider Interface

ISynchronousDataRetriever Interface

ISyncProvider Interface

ISynchronousNotifyingChangeApplierTarget Interface

KnowledgeSyncProvider

SyncProvider

IChangeDataRetriever

INotifyingChangeApplierTarget

Concepts

Microsoft Sync Framework

How to: Create an Unmanaged Synchronization Provider

Enumerating Changes

Handling Conflicts

Applying Changes

Synchronizing Change Units

Reporting Synchronization Progress

Filtering Synchronization Data

Supporting Concurrent Synchronization Tasks

Considerations for Standard Custom Provider Design

Interoperating with FeedSync Feeds

Recovering an Out-of-Date Replica