語言

IdentityRule 類別

定義用來在複寫中識別項目的方式。

命名空間: Microsoft.Synchronization.SimpleProviders
組件: Microsoft.Synchronization.SimpleProviders (在 microsoft.synchronization.simpleproviders.dll)

語法

'宣告
Public Class IdentityRule
'用途
Dim instance As IdentityRule
public class IdentityRule
public ref class IdentityRule
public class IdentityRule
public class IdentityRule

備註

識別規則會指定應該使用哪個或哪些自訂欄位 (CustomFields) 來識別項目存放區中的項目或變更單位。如需簡單提供者中繼資料的詳細資訊,請參閱管理簡單提供者的中繼資料。

範例

下列程式碼範例提供 ItemMetadataSchema 物件的輸入。範例程式碼中的常數定義項目存放區中每一資料行的整數值。這些值是在建立自訂欄位定義和 ItemMetadataSchema 物件的識別規則時使用。若要在完整應用程式的內容中檢視這段程式碼,請參閱 Sync Framework SDK 及 Code Gallery 中的 "Sync101 using Simple Sync Provider" 應用程式。

public const uint CUSTOM_FIELD_ID = 1;
public const uint CUSTOM_FIELD_TIMESTAMP = 2;
public override ItemMetadataSchema MetadataSchema
{
    get
    {
        CustomFieldDefinition[] customFields = new CustomFieldDefinition[2];
        customFields[0] = new CustomFieldDefinition(CUSTOM_FIELD_ID, typeof(ulong));
        customFields[1] = new CustomFieldDefinition(CUSTOM_FIELD_TIMESTAMP, typeof(ulong));

        IdentityRule[] identityRule = new IdentityRule[1];
        identityRule[0] = new IdentityRule(new uint[] { CUSTOM_FIELD_ID });

        return new ItemMetadataSchema(customFields, identityRule);
    }
}
Public Const CUSTOM_FIELD_ID As UInteger = 1
Public Const CUSTOM_FIELD_TIMESTAMP As UInteger = 2
Public Overrides ReadOnly Property MetadataSchema() As ItemMetadataSchema
    Get
        Dim customFields As CustomFieldDefinition() = New CustomFieldDefinition(1) {}
        customFields(0) = New CustomFieldDefinition(CUSTOM_FIELD_ID, GetType(ULong))
        customFields(1) = New CustomFieldDefinition(CUSTOM_FIELD_TIMESTAMP, GetType(ULong))

        Dim identityRule As IdentityRule() = New IdentityRule(0) {}
        identityRule(0) = New IdentityRule(New UInteger() {CUSTOM_FIELD_ID})

        Return New ItemMetadataSchema(customFields, identityRule)
    End Get
End Property

繼承階層

System.Object
  Microsoft.Synchronization.SimpleProviders.IdentityRule

執行緒安全性

任何公用靜態 (共用 在 Visual Basic) 此型別的成員具備執行緒安全。不保證任何執行個體成員安全執行緒。

請參閱

參考

IdentityRule 成員
Microsoft.Synchronization.SimpleProviders 命名空間