共用方式為


IdFormats 屬性

在衍生類別中覆寫時,會取得代表複寫和項目識別碼之格式的 SyncIdFormatGroup 物件。

命名空間:  Microsoft.Synchronization.SimpleProviders
組件:  Microsoft.Synchronization.SimpleProviders (在 Microsoft.Synchronization.SimpleProviders.dll 中)

語法

'宣告
Public MustOverride ReadOnly Property IdFormats As SyncIdFormatGroup
    Get
'用途
Dim instance As SimpleSyncProvider
Dim value As SyncIdFormatGroup

value = instance.IdFormats
public abstract SyncIdFormatGroup IdFormats { get; }
public:
virtual property SyncIdFormatGroup^ IdFormats {
    SyncIdFormatGroup^ get () abstract;
}
abstract IdFormats : SyncIdFormatGroup
abstract function get IdFormats () : SyncIdFormatGroup

屬性值

型別:Microsoft.Synchronization. . :: . .SyncIdFormatGroup
用來定義複寫和項目識別碼之格式的 SyncIdFormatGroup 物件。

備註

若要同步處理某個項目,Sync Framework 必須能夠在項目存放區中識別此項目,並將該識別對應到中繼資料存放區中的內部識別碼。要彼此同步處理的提供者必須使用通用格式的複寫和項目識別碼 (由 IdFormats 屬性指定)。

範例

下列程式碼定義 MyFullEnumerationSimpleSyncProvider 範例類別和 IdFormats 屬性的建構函式。如此可讓 Sync Framework 執行階段判斷中繼資料存放區用於識別碼的格式。如果未使用彈性識別碼,Sync Framework 會使用固定格式來識別複寫、項目和變更單位。如果使用了彈性識別碼,則會使用 ISimpleSyncProviderIdGenerator 方法來產生識別碼。若要在完整應用程式的內容中檢視這段程式碼,請參閱 Sync Framework SDK 及 Code Gallery 中的 "Sync101 using Simple Sync Provider" 應用程式。

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

請參閱

參考

SimpleSyncProvider類別

SimpleSyncProvider 成員

Microsoft.Synchronization.SimpleProviders 命名空間