SimpleSyncProvider.IdFormats Property
When overridden in a derived class, gets a SyncIdFormatGroup object that represents the format of replica and item IDs.
Namespace: Microsoft.Synchronization.SimpleProviders
Assembly: Microsoft.Synchronization.SimpleProviders (in microsoft.synchronization.simpleproviders.dll)
Syntax
'Declaration
Public MustOverride ReadOnly Property IdFormats As SyncIdFormatGroup
'Usage
Dim instance As SimpleSyncProvider
Dim value As SyncIdFormatGroup
value = instance.IdFormats
public abstract SyncIdFormatGroup IdFormats { get; }
public:
virtual property SyncIdFormatGroup^ IdFormats {
SyncIdFormatGroup^ get () abstract;
}
/** @property */
public abstract SyncIdFormatGroup get_IdFormats ()
public abstract function get IdFormats () : SyncIdFormatGroup
Property Value
A SyncIdFormatGroup object that is used to define the format of replica and item IDs.
Remarks
To synchronize an item, Sync Framework must be able to identify the item in the item store and map that identity to an internal ID in the metadata store. Providers that synchronize with each other must use a common format for replica and item IDs, which is specified by the IdFormats property.
Example
The following code defines the constructor for the MyFullEnumerationSimpleSyncProvider
sample class and the IdFormats property. This enables the Sync Framework runtime to determine what format the metadata store uses for IDs. If flexible IDs are not used, Sync Framework uses a fixed format to identify replicas, items, and change units. If flexible IDs are used, ISimpleSyncProviderIdGenerator methods are used to generate IDs. To view this code in the context of a complete application, see the "Sync101 using Simple Sync Provider"
application that is available in the Sync Framework SDK and from Code Gallery.
public MyFullEnumerationSimpleSyncProvider(string name, MySimpleDataStore store)
{
_name = name;
_store = store;
// Create a file to store metadata for all items and a file to store
// the replica ID.
_replicaMetadataFile = Environment.CurrentDirectory + "\\" + _name.ToString() + ".Metadata";
_replicaIdFile = Environment.CurrentDirectory + "\\" + _name.ToString() + ".Replicaid";
// Set ReplicaIdFormat to use a GUID as an ID, and ItemIdFormat to use a GUID plus
// an 8-byte prefix.
_idFormats = new SyncIdFormatGroup();
_idFormats.ItemIdFormat.IsVariableLength = false;
_idFormats.ItemIdFormat.Length = 24;
_idFormats.ReplicaIdFormat.IsVariableLength = false;
_idFormats.ReplicaIdFormat.Length = 16;
this.ItemConstraint += new EventHandler<SimpleSyncItemConstraintEventArgs>(OnItemConstraint);
this.ItemConflicting += new EventHandler<SimpleSyncItemConflictingEventArgs>(OnItemConflicting);
}
public SyncId ReplicaId
{
get
{
if (_replicaId == null)
{
_replicaId = GetReplicaIdFromFile( _replicaIdFile);
}
return _replicaId;
}
}
public override SyncIdFormatGroup IdFormats
{
get { return _idFormats; }
}
Public Sub New(ByVal name As String, ByVal store As MySimpleDataStore)
_name = name
_store = store
' Create a file to store metadata for all items and a file to store
' the replica ID.
_replicaMetadataFile = (Environment.CurrentDirectory & "\") + _name.ToString() & ".Metadata"
_replicaIdFile = (Environment.CurrentDirectory & "\") + _name.ToString() & ".Replicaid"
' Set ReplicaIdFormat to use a GUID as an ID, and ItemIdFormat to use a GUID plus
' an 8-byte prefix.
_idFormats = New SyncIdFormatGroup()
_idFormats.ItemIdFormat.IsVariableLength = False
_idFormats.ItemIdFormat.Length = 24
_idFormats.ReplicaIdFormat.IsVariableLength = False
_idFormats.ReplicaIdFormat.Length = 16
AddHandler Me.ItemConstraint, AddressOf HandleItemConstraint
AddHandler Me.ItemConflicting, AddressOf HandleItemConflicting
End Sub
Public ReadOnly Property ReplicaId() As SyncId
Get
If _replicaId Is Nothing Then
_replicaId = GetReplicaIdFromFile(_replicaIdFile)
End If
Return _replicaId
End Get
End Property
Public Overrides ReadOnly Property IdFormats() As SyncIdFormatGroup
Get
Return _idFormats
End Get
End Property
See Also
Reference
SimpleSyncProvider Class
SimpleSyncProvider Members
Microsoft.Synchronization.SimpleProviders Namespace