ItemFieldDictionary Class

Represents an item and its associated fields.

Inheritance Hierarchy

System.Object
  Microsoft.Synchronization.SimpleProviders.ItemFieldDictionary

Namespace:  Microsoft.Synchronization.SimpleProviders
Assembly:  Microsoft.Synchronization.SimpleProviders (in Microsoft.Synchronization.SimpleProviders.dll)

Syntax

'Declaration
Public Class ItemFieldDictionary _
    Implements IDictionary(Of UInteger, ItemField),  _
    ICollection(Of KeyValuePair(Of UInteger, ItemField)), IEnumerable(Of KeyValuePair(Of UInteger, ItemField)),  _
    IEnumerable
'Usage
Dim instance As ItemFieldDictionary
public class ItemFieldDictionary : IDictionary<uint, ItemField>, 
    ICollection<KeyValuePair<uint, ItemField>>, IEnumerable<KeyValuePair<uint, ItemField>>, 
    IEnumerable
public ref class ItemFieldDictionary : IDictionary<unsigned int, ItemField^>, 
    ICollection<KeyValuePair<unsigned int, ItemField^>>, IEnumerable<KeyValuePair<unsigned int, ItemField^>>, 
    IEnumerable
type ItemFieldDictionary =  
    class
        interface IDictionary<uint32, ItemField>
        interface ICollection<KeyValuePair<uint32, ItemField>>
        interface IEnumerable<KeyValuePair<uint32, ItemField>>
        interface IEnumerable
    end
public class ItemFieldDictionary implements IDictionary<uint, ItemField>, ICollection<KeyValuePair<uint, ItemField>>, IEnumerable<KeyValuePair<uint, ItemField>>, IEnumerable

The ItemFieldDictionary type exposes the following members.

Constructors

  Name Description
Public method ItemFieldDictionary() Initializes a new instance of the ItemFieldDictionary class.
Public method ItemFieldDictionary(IEnumerable<ItemField>) Initializes a new instance of the ItemFieldDictionary class that contains a collection of ItemField objects.

Top

Properties

  Name Description
Public property Count Gets the number of ItemField objects in the ItemFieldDictionary collection.
Public property IsReadOnly Indicates whether a value the ItemFieldDictionary collection is read-only.
Public property Item Gets or sets the ItemField object that corresponds to the specified key.
Public property Keys Gets a collection of the keys that are contained in the ItemFieldDictionary collection.
Public property Values Gets a collection of the values that are contained in the ItemFieldDictionary collection.

Top

Methods

  Name Description
Public method Add(KeyValuePair<UInt32, ItemField>) Adds an ItemField object to the ItemFieldDictionary collection.
Public method Add(ItemField) Adds an ItemField object to the ItemFieldDictionary collection.
Public method Add(UInt32, ItemField) Adds an ItemField object to the ItemFieldDictionary collection.
Public method Clear Removes all ItemField objects from the ItemFieldDictionary collection.
Public method Contains Indicates whether an ItemField object is contained in the ItemFieldDictionary collection.
Public method ContainsKey Indicates whether the ItemFieldDictionary collection contains an ItemField object with the specified key.
Public method CopyTo Copies the elements of the ItemFieldDictionary collection to the specified array.
Public method Equals (Inherited from Object.)
Protected method Finalize (Inherited from Object.)
Public method GetEnumerator Returns an IEnumerator object that enables you to iterate through the ItemFieldDictionary collection.
Public method GetHashCode (Inherited from Object.)
Public method GetType (Inherited from Object.)
Protected method MemberwiseClone (Inherited from Object.)
Public method Remove(KeyValuePair<UInt32, ItemField>) Removes the specified ItemField object from the ItemFieldDictionary collection.
Public method Remove(UInt32) Removes the ItemField object with the specified key from the ItemFieldDictionary collection.
Public method ToString (Inherited from Object.)
Public method TryGetValue Gets the value associated with the specified key.

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method IEnumerable<KeyValuePair<UInt32, ItemField>>.GetEnumerator Returns an IEnumerator object that enables you to iterate through the ItemFieldDictionary collection.
Explicit interface implemetationPrivate method IEnumerable.GetEnumerator Returns an IEnumerator object that enables you to iterate through the ItemFieldDictionary collection.

Top

Remarks

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.

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.

See Also

Reference

Microsoft.Synchronization.SimpleProviders Namespace