## How it works
`EPiServer.Core.IContentData
` is the base interface that all content models implement. All content types, except `BlockData
`, also implement the `EPiServer.Core.IContent
` interface, which is required for a content instance to have a unique ID and its own lifecycle (that is, can be loaded/saved individually). Through the `EPiServer.IContentRepository
`, you can perform CRUD (Create, Read, Update, Delete) operations on content instances implementing `EPiServer.Core.IContent
`, for example, listing and move.
There are also many additional metadata interfaces a content type can implement that define the characteristics of the content type. Here is a list of the existing metadata interfaces with a description on the purpose of each interface and which properties they contain.
## Usage
Because some of the interfaces are optional, a recommended pattern when working with a "general" `IContent
` instance is to use the **is **or **as** operators to check if the instance implements an interface, as in this example:
### Shared blocks
`BlockData
` does not implement `IContent
`, while shared block instances still have their own identity defined on `IContent
`. This is accomplished so that during runtime, when a shared block instance is created (for example, through a call to `IContentRepository.GetDefault<T>
` where T is a type inheriting from BlockData), the CMS creates a new .NET type inheriting T using a technique called **mixin** where the new generated subclass will implement some extra interfaces (including IContent).
That means that a shared block instance of T will implement `IContent
` while an instance of T that is a property on a Page will not.
## IContentData
Base interface for all content models. It contains a backing `PropertyDataCollection
` that is used when loading/saving data from database.
Member | Type | Description |
`Property ` | `PropertyDataCollection ` | Contains backing data for properties used by the content instance. |
## IContent
Base interface for all content models that can have an own identity, and hence can be loaded/saved individually. `IContent
` inherits `IContentData
`. Note that `ContentLink.ID
` and `ContentGuid
` is the same for all language branches for a content item. So the combination of `ContentLink
`/`ContentGuid
` and `ILocale.Language
` uniquely specifies the content instance (given that the content implements `ILocalizable
`). All built-in base content types, except `BlockData
`, implement `IContent
`. Shared block instances implement `IContent
` (and most other metadata interfaces) at runtime.
Member | Type | Description |
`Name ` | `string ` | The name of the content instance. |
`ContentLink ` | `ContentReference ` | The identifier of the content instance. WorkID specifies an optional version ID, in case the instance represents a specific version. |
`ContentGuid ` | `Guid ` | A GUID-based identifier for the content instance. |
`ParentLink ` | `ContentReference ` | The parent identifier (in a tree structure) for the content instance. |
`ContentTypeID ` | `int ` | An identifier that specifies which content type the content is an instance of. |
`IsDeleted ` | `bool ` | Indicates if the content instance is in the wastebasket. |
`Property ` | `PropertyDataCollection ` | Inherited from `IContentData `. |
## IVersionable
An optional interface for content that supports different versions for each language branch. There can only be at most one version published at each time. All built-in types, except `ContentFolder
`, implement `IVersionable
`. See [Content versions](🔗) for more information regarding versions.
Member | Type | Description |
`Status ` | `VersionStatus ` | Specifies the status of the content version. |
`IsPendingPublish ` | `bool ` | Specifies if there is any published version for the current language branch. |
`StartPublish ` | `DateTime? ` | Optional value that specifies when the content is/was published. |
`StopPublish ` | `DateTime? ` | Optional value that specifies when the content is/was depublished. |
## ILocale
An optional interface for content that specifies which language a specific content instance has. All built-in types except `ContentFolder
` implements `ILocale
`.
Member | Type | Description |
`Language ` | `CultureInfo ` | Specifies the language of a content instance. `CultureInfo.InvariantCulture ` means that the content instance is not culture specific. |
## ILocalizable
An optional interface for content that support multiple language branches. Inherits `ILocale
`. All built-in types, except `ContentFolder
` and `MediaData
`, implement `ILocalizable
`.
Member | Type | Description |
`Language ` | `CultureInfo ` | Inherits from `ILocale `. |
`MasterLanguage ` | `CultureInfo ` | Specifies which language version that contains the none language-specific properties. |
`ExistingLanguages ` | `IEnumerable<CultureInfo> ` | Specifies all existing language branches for this content. |
## IReadOnly/IReadOnly<T>
An optional interface for content that support read-only instances. It is highly recommended that content types implement `IReadOnly
`, which ensures the integrity of the content instances when instances are served from cache and hence reused across different requests. All built-in base content classes implement `IReadOnly
`.
Member | Type | Description |
`IsReadOnly ` | `bool ` | Specifies if the current instance is read-only. |
`void MakeReadOnly() ` | `Method ` | Makes an instance read-only. |
`object/T CreateWritableClone() ` | `Method ` | Creates a writable clone from a read-only instance. |
## IModifiedTrackable
An optional interface for content instances that support modified tracking. There is a high performance gain during save operations if `IModifiedTrackable
` since then only data that has actually changed needs to be persisted. All built-in base content classes implement `IModifiedTrackable
`.
Member | Type | Description |
`IsModified ` | `bool ` | Specifies it the current instance is modified. |
`void ResetModified() ` | `Method ` | Sets the content instance in a none modified state. |
## IChangeTrackable
An optional interface for content instances that support tracking of changes. All built-in base content classes implement `IChangeTrackable
`.
Member | Type | Description |
`IsModified ` | `bool ` | Specifies if the current instance is modified. |
`void ResetModified() ` | `Method ` | Sets the content instance in a none modified state. |
## IContentSecurable
An optional interface for content instances that support access checks. All built-in base content classes implement `IContentSecurable
`.
Member | Type | Description |
`IContentSecurityDescriptor GetContentSecurityDescriptor() ` | `Method ` | Gets the security descriptor for the content instance where access rights can be checked. |
## IRoutable
An interface that content items that should be routable through a content URL should implement. All built-in base content classes, except shared blocks, implement `IRoutable
`.
Member | Type | Description |
`RouteSegment ` | `string ` | Specifies the route segment that is used for the content instance in the hierarchical content url. |
## ICategorizable
An interface that content items that should be possible to categorize should implement. All built-in base content classes, except content folders, implement `ICategorizable
`.
Member | Type | Description |
`Category ` | `CategoryList ` | A list of all categories that this content instance is categorized as. |
## IInitializableContent
An optional interface that content items that can be implemented if default values should be added when a new instance of the content type is created.
Member | Type | Description |
`void SetDefaultValues(ContentType contentType) ` | `Method ` | Called when a new instance of the content type is created. |
## IExportable
An optional interface that specifies how a content instance should be handled during export.
Member | Type | Description |
`ShouldBeImplicitlyExported ` | `bool ` | Specifies whether this instance should be implicitly added to export package when referenced by some entity that is exported. |