SimpleSyncProvider.IdFormats Property
When overridden in a derived class, gets a SyncIdFormatGroup object that represents the format of replica and item IDs.
Assembly: Microsoft.Synchronization.SimpleProviders (in Microsoft.Synchronization.SimpleProviders.dll)
'Declaration Public MustOverride ReadOnly Property IdFormats As SyncIdFormatGroup Get 'Usage Dim instance As SimpleSyncProvider Dim value As SyncIdFormatGroup value = instance.IdFormats
Property Value
Type: Microsoft.Synchronization.SyncIdFormatGroupA SyncIdFormatGroup object that is used to define the format of replica and item IDs.
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
Show: