ItemField Class
Represents the way in which an item is identified when changes are applied to a destination.
Inheritance Hierarchy
System.Object
Microsoft.Synchronization.SimpleProviders.ItemField
Namespace: Microsoft.Synchronization.SimpleProviders
Assembly: Microsoft.Synchronization.SimpleProviders (in Microsoft.Synchronization.SimpleProviders.dll)
Syntax
'Declaration
Public Class ItemField
'Usage
Dim instance As ItemField
public class ItemField
public ref class ItemField
type ItemField = class end
public class ItemField
The ItemField type exposes the following members.
Constructors
Name | Description | |
---|---|---|
ItemField | Initializes a new instance of the ItemField class that contains a field ID, a field type, and a metadata value for the field. |
Top
Properties
Name | Description | |
---|---|---|
FieldId | An integer ID for the field. | |
FieldSize | Gets the size associated with the field, such as the length of the string or byte array that it will store. | |
FieldType | Gets the data type of the field. | |
Value | Gets the metadata value that is stored in the item field. |
Top
Methods
Name | Description | |
---|---|---|
Equals | Determines whether a ItemField object is equal to the specified object. (Overrides Object.Equals(Object).) | |
Finalize | (Inherited from Object.) | |
GetHashCode | Serves as a hash function for a ItemField. This is suitable for use in hashing algorithms and data structures such as a hash table. (Overrides Object.GetHashCode().) | |
GetType | (Inherited from Object.) | |
MemberwiseClone | (Inherited from Object.) | |
ToString | (Inherited from Object.) |
Top
Examples
The following code examples show an implementation of the EnumerateItems method for a sample application that stores items in an in-memory store. The CreateItemFieldDictionary method is a sample method that creates and returns an ItemFieldDictionary object for each item in the store. 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 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
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.