Is this really the version you are looking for? Kentico Xperience 12 Service Pack Documentation is no longer updated. Use the switcher in the header to choose your product version.
Object type information is code that sets the metadata of classes in Kentico. The system uses the type information to determine the basic properties and behavior of objects of the given class, including the following areas:
The type information is defined in the code of individual Info classes and consists of the following basic parts:
Terminology - Classes and Object types
To make the concepts easier to understand for developers who are new to class development in Kentico, the documentation uses the term "class" to refer to the sum of all metadata defined by a type information instance. This terminology matches the classes that you create in the administration interface of the Modules application. Technically, each type information definition represents an "object type" rather than a class, and some of the default Kentico classes have multiple type information definitions.
Note: The comments and XML-based documentation in the Kentico API use the term "object type" for this purpose.
Tip: You can find an overview of the available object types in the Kentico administration interface. Open the System application and view the Object types tab.
After creating a new class for a custom module in the Modules application, you can generate basic Info and InfoProvider class files on the Code tab of the class editing interface. The default code of the Info class automatically includes:
Click Save code to create the class files in your project. You can then adjust the type information in the code of the given Info class:
Open your Kentico solution in Visual Studio.
Edit the Info class representing your module class.
Navigate to the TYPEINFO field in the class's code.
Set the parameters in the ObjectTypeInfo constructor:
providerType - the Type (opens in a new tab) of the class's InfoProvider class. For example: typeof(ForumPostInfoProvider)
objectType
objectClassName
Class identifiers
Kentico classes have two different identifiers:
idColumn - the name of the class field that stores the IDs of objects (i.e. the primary key column). Can be null in rare cases (for example binding classes without an identity column).
timeStampColumn - the name of the class field that stores the last modification date for objects. Can be null.
guidColumn - the name of the class field that stores the GUID identifiers (opens in a new tab) of objects. Can be null.
codeNameColumn - the name of the class field that stores the unique text identifiers of objects. Can be null for classes without a dedicated code name column.
displayNameColumn - the name of the class field that stores the visible names of objects (names used in the administration interface or on the live site). Can be null.
binaryColumn - the name of the class field that stores binary data for objects. Can be null.
siteIDColumn - the name of the class field that stores site IDs for site-related objects. Can be null. Only use site ID columns if you do not have a separate binding class for the site relationship.
parentIDColumn - the name of the class field that stores the IDs of parent objects. Set to null for classes without a parent class. See Setting parent-child relationships for classes to learn more.
parentObjectType - the object type name of the class's parent (as defined in the type information of the parent class). Set to null for classes without a parent class.
Use the initializer (opens in a new tab) to set other properties for the ObjectTypeInfo object.
You can use the type information to configure a large number of scenarios and options for your classes. See the following sections to learn about the most common scenarios:
Define fields for your custom classes that store references (foreign keys) to objects of other classes and vice versa.
Use the type information to define a hierarchy for the classes representing your module's data. Setting parent-child relationships for classes ensures that the system can provide many types of automatic behavior.
Configure the type information of your custom classes to allow transferring of data through the Export - Import and Staging features.
Configure the type information of your custom classes to support synchronization of data using the Kentico continuous integration solution.
The following code is an advanced ObjectTypeInfo example. This instance contains the metadata of the system's forum post objects (defined in the ForumPostInfo class).
[assembly: RegisterObjectType(typeof(ForumPostInfo), ForumPostInfo.OBJECT_TYPE)]
...
public class ForumPostInfo : AbstractInfo<ForumPostInfo>, ISearchable
{
// Sets the object type name for the forum post class
public const string OBJECT_TYPE = "forums.forumpost";
public static ObjectTypeInfo TYPEINFO = new ObjectTypeInfo(typeof(ForumPostInfoProvider), OBJECT_TYPE, "Forums.ForumPost", "PostID", "PostLastModified", "PostGUID", null, "PostSubject", null, "PostSiteID", "PostForumID", ForumInfo.OBJECT_TYPE)
{
DependsOn = new List<ObjectDependency>
{
new ObjectDependency("PostParentID", OBJECT_TYPE, ObjectDependencyEnum.NotRequired),
new ObjectDependency("PostApprovedByUserID", UserInfo.OBJECT_TYPE, ObjectDependencyEnum.NotRequired),
new ObjectDependency("PostUserID", UserInfo.OBJECT_TYPE, ObjectDependencyEnum.NotRequired)
},
LogEvents = true,
TouchCacheDependencies = true,
SupportsVersioning = false,
AllowRestore = false,
ModuleName = "cms.forums",
SupportsCloning = false,
ObjectIDPathColumn = "PostIDPath",
ObjectLevelColumn = "PostLevel",
OrderColumn = "PostStickOrder",
RegisterAsChildToObjectTypes = new List<string>
{
ForumInfo.OBJECT_TYPE,
ForumInfo.OBJECT_TYPE_GROUP
},
ImportExportSettings =
{
IncludeToExportParentDataSet = IncludeToParentEnum.None,
LogExport = false,
LogProgress = false
},
SynchronizationSettings =
{
LogSynchronization = SynchronizationTypeEnum.None,
IncludeToSynchronizationParentDataSet = IncludeToParentEnum.None
}
};
...
}A single Info class can have multiple type information definitions representing different variants of the class. All variants share the same Info code and database class record. Each type information definition must be registered under a unique object type name using a separate RegisterObjectType assembly attribute.
An example from the Kentico system classes is CategoryInfo, which has one ObjectTypeInfo instance for global and site page categories and another for personal categories that belong to individual users.
We do not recommend creating custom classes with multiple type information definitions. Such classes require more complex type information settings or custom coding to achieve certain scenarios.
Handling of object type name requests
The following points summarize how the system loads the correct metadata when an object type name is requested: