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 | |
---|---|---|
ItemFieldDictionary() | Initializes a new instance of the ItemFieldDictionary class. | |
ItemFieldDictionary(IEnumerable<ItemField>) | Initializes a new instance of the ItemFieldDictionary class that contains a collection of ItemField objects. |
Top
Properties
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. |
Top
Methods
Name | Description | |
---|---|---|
Add(KeyValuePair<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<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. |
Top
Explicit Interface Implementations
Name | Description | |
---|---|---|
IEnumerable<KeyValuePair<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. |
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.