ItemField 類別
表示當變更套用至目的地時,用來識別項目的方式。
命名空間: Microsoft.Synchronization.SimpleProviders
組件: Microsoft.Synchronization.SimpleProviders (在 microsoft.synchronization.simpleproviders.dll)
語法
'宣告
Public Class ItemField
'用途
Dim instance As ItemField
public class ItemField
public ref class ItemField
public class ItemField
public class ItemField
範例
下列程式碼範例針對將項目儲存在記憶體中存放區的範例應用程式示範 EnumerateItems 方法的實作。CreateItemFieldDictionary
方法是範例方法,它會針對存放區中的每一項目建立並傳回 ItemFieldDictionary 物件。若要在完整應用程式的內容中檢視這段程式碼,請參閱 Sync Framework SDK 及 Code Gallery 中的 "Sync101 using Simple Sync Provider"
應用程式。
public override void EnumerateItems(FullEnumerationContext context)
{
List<ItemFieldDictionary> items = new List<ItemFieldDictionary>();
foreach (ulong id in _store.Ids)
{
items.Add(_store.CreateItemFieldDictionary(id));
}
context.ReportItems(items);
}
public ItemFieldDictionary CreateItemFieldDictionary(ulong id)
{
ItemFieldDictionary itemFields = null;
if (_store.ContainsKey(id))
{
itemFields = new ItemFieldDictionary();
itemFields.Add(new ItemField(MyFullEnumerationSimpleSyncProvider.CUSTOM_FIELD_ID, typeof(ulong), id));
itemFields.Add(new ItemField(MyFullEnumerationSimpleSyncProvider.CUSTOM_FIELD_TIMESTAMP, typeof(ulong), _store[id].TimeStamp));
}
else
{
throw new Exception("Item does not exist in store");
}
return itemFields;
}
Public Overrides Sub EnumerateItems(ByVal context As FullEnumerationContext)
Dim items As New List(Of ItemFieldDictionary)()
For Each id As ULong In _store.Ids
items.Add(_store.CreateItemFieldDictionary(id))
Next
context.ReportItems(items)
End Sub
Public Function CreateItemFieldDictionary(ByVal id As ULong) As ItemFieldDictionary
Dim itemFields As ItemFieldDictionary = Nothing
If _store.ContainsKey(id) Then
itemFields = New ItemFieldDictionary()
itemFields.Add(New ItemField(MyFullEnumerationSimpleSyncProvider.CUSTOM_FIELD_ID, GetType(ULong), id))
itemFields.Add(New ItemField(MyFullEnumerationSimpleSyncProvider.CUSTOM_FIELD_TIMESTAMP, GetType(ULong), _store(id).TimeStamp))
Else
Throw New Exception("Item does not exist in store")
End If
Return itemFields
End Function
繼承階層
System.Object
Microsoft.Synchronization.SimpleProviders.ItemField
執行緒安全性
任何公用靜態 (共用 在 Visual Basic) 此型別的成員具備執行緒安全。不保證任何執行個體成員安全執行緒。