ItemFieldDictionary Class
Represents an item and its associated fields.
Assembly: Microsoft.Synchronization.SimpleProviders (in Microsoft.Synchronization.SimpleProviders.dll)
The ItemFieldDictionary type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | ItemFieldDictionary | Initializes a new instance of the ItemFieldDictionary class. |
![]() | ItemFieldDictionary(IEnumerable(Of ItemField)) | Initializes a new instance of the ItemFieldDictionary class that contains a collection of ItemField objects. |
| Name | Description | |
|---|---|---|
![]() | Count | Gets the number of ItemField objects in the ItemFieldDictionary collection. |
![]() | IsReadOnly | Indicates whether a value the ItemFieldDictionary collection is read-only. |
![]() | Item | Gets or sets the ItemField object that corresponds to the specified key. |
![]() | Keys | Gets a collection of the keys that are contained in the ItemFieldDictionary collection. |
![]() | Values | Gets a collection of the values that are contained in the ItemFieldDictionary collection. |
| Name | Description | |
|---|---|---|
![]() | Add(KeyValuePair(Of UInt32, ItemField)) | Adds an ItemField object to the ItemFieldDictionary collection. |
![]() | Add(ItemField) | Adds an ItemField object to the ItemFieldDictionary collection. |
![]() | Add(UInt32, ItemField) | Adds an ItemField object to the ItemFieldDictionary collection. |
![]() | Clear | Removes all ItemField objects from the ItemFieldDictionary collection. |
![]() | Contains | Indicates whether an ItemField object is contained in the ItemFieldDictionary collection. |
![]() | ContainsKey | Indicates whether the ItemFieldDictionary collection contains an ItemField object with the specified key. |
![]() | CopyTo | Copies the elements of the ItemFieldDictionary collection to the specified array. |
![]() | Equals | (Inherited from Object.) |
![]() | Finalize | (Inherited from Object.) |
![]() | GetEnumerator | Returns an IEnumerator object that enables you to iterate through the ItemFieldDictionary collection. |
![]() | GetHashCode | (Inherited from Object.) |
![]() | GetType | (Inherited from Object.) |
![]() | MemberwiseClone | (Inherited from Object.) |
![]() | Remove(KeyValuePair(Of UInt32, ItemField)) | Removes the specified ItemField object from the ItemFieldDictionary collection. |
![]() | Remove(UInt32) | Removes the ItemField object with the specified key from the ItemFieldDictionary collection. |
![]() | ToString | (Inherited from Object.) |
![]() | TryGetValue | Gets the value associated with the specified key. |
| Name | Description | |
|---|---|---|
![]() ![]() | IEnumerable(Of KeyValuePair(Of UInt32, ItemField)).GetEnumerator | Returns an IEnumerator object that enables you to iterate through the ItemFieldDictionary collection. |
![]() ![]() | IEnumerable.GetEnumerator | Returns an IEnumerator object that enables you to iterate through the ItemFieldDictionary collection. |
ItemFieldDictionary objects are used by many of the simple provider methods to store and pass the ItemField objects that identify items when changes are applied to a destination.
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
