CustomFieldDefinition Class
Represents a field that can be used to identify an item in the metadata store or to store version-related information for an item or a change unit.
Inheritance Hierarchy
System.Object
Microsoft.Synchronization.SimpleProviders.CustomFieldDefinition
Namespace: Microsoft.Synchronization.SimpleProviders
Assembly: Microsoft.Synchronization.SimpleProviders (in Microsoft.Synchronization.SimpleProviders.dll)
Syntax
'Declaration
Public Class CustomFieldDefinition
'Usage
Dim instance As CustomFieldDefinition
public class CustomFieldDefinition
public ref class CustomFieldDefinition
type CustomFieldDefinition = class end
public class CustomFieldDefinition
The CustomFieldDefinition type exposes the following members.
Constructors
Name | Description | |
---|---|---|
CustomFieldDefinition(UInt32, Type) | Initializes a new instance of the CustomFieldDefinition class that contains a field ID and a field type. | |
CustomFieldDefinition(UInt32, Type, UInt32) | Initializes a new instance of the CustomFieldDefinition class that contains a field ID, a field type, and field size. |
Top
Properties
Name | Description | |
---|---|---|
FieldId | Gets the 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. |
Top
Methods
Name | Description | |
---|---|---|
Equals | (Inherited from Object.) | |
Finalize | (Inherited from Object.) | |
GetHashCode | (Inherited from Object.) | |
GetType | (Inherited from Object.) | |
MemberwiseClone | (Inherited from Object.) | |
ToString | (Inherited from Object.) |
Top
Remarks
Custom fields are fields in the metadata store that are identified by integers. If an application requires a friendly name for one or more fields, it should map the integer to a name. Custom fields are defined for two reasons: to identify items, and to provide version information about those items. Version fields enable Sync Framework to determine if an item or change unit has changed. For more information about simple provider metadata, see Managing Metadata for Simple Providers.
Custom fields can be of the following data types. For fixed length types, use the two-parameter constructor CustomFieldDefinition. For variable length types, use the three-parameter constructor CustomFieldDefinition.
Type |
Constructor |
---|---|
Byte |
|
Byte[] |
|
Guid |
|
String |
|
UInt16 |
|
UInt32 |
|
UInt64 |
Examples
The following code examples provide input for the ItemMetadataSchema object. The constants in the sample code define an integer value for each column in the item store. These values are used when creating the custom field definitions and identity rules for the ItemMetadataSchema object. 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 const uint CUSTOM_FIELD_ID = 1;
public const uint CUSTOM_FIELD_TIMESTAMP = 2;
public override ItemMetadataSchema MetadataSchema
{
get
{
CustomFieldDefinition[] customFields = new CustomFieldDefinition[2];
customFields[0] = new CustomFieldDefinition(CUSTOM_FIELD_ID, typeof(ulong));
customFields[1] = new CustomFieldDefinition(CUSTOM_FIELD_TIMESTAMP, typeof(ulong));
IdentityRule[] identityRule = new IdentityRule[1];
identityRule[0] = new IdentityRule(new uint[] { CUSTOM_FIELD_ID });
return new ItemMetadataSchema(customFields, identityRule);
}
}
Public Const CUSTOM_FIELD_ID As UInteger = 1
Public Const CUSTOM_FIELD_TIMESTAMP As UInteger = 2
Public Overrides ReadOnly Property MetadataSchema() As ItemMetadataSchema
Get
Dim customFields As CustomFieldDefinition() = New CustomFieldDefinition(1) {}
customFields(0) = New CustomFieldDefinition(CUSTOM_FIELD_ID, GetType(ULong))
customFields(1) = New CustomFieldDefinition(CUSTOM_FIELD_TIMESTAMP, GetType(ULong))
Dim identityRule As IdentityRule() = New IdentityRule(0) {}
identityRule(0) = New IdentityRule(New UInteger() {CUSTOM_FIELD_ID})
Return New ItemMetadataSchema(customFields, identityRule)
End Get
End Property
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.