Try our conversational search powered by Generative AI!

Class ContentType

Basic type information and comparison between types

Inheritance
System.Object
ContentType
Implements
System.IComparable
System.IComparable<ContentType>
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.DataAbstraction
Assembly: EPiServer.dll
Version: 11.20.7
Syntax
public class ContentType : IComparable, IComparable<ContentType>, IReadOnly

Constructors

ContentType()

Initializes a new instance of the ContentType class.

Declaration
public ContentType()

ContentType(Int32, Guid, String, String, Boolean, Int32)

Initializes a new instance of the ContentType class.

Declaration
[Obsolete("Use alternative constructor")]
protected ContentType(int id, Guid guid, string name, string description, bool isAvailable, int sortOrder)
Parameters
Type Name Description
System.Int32 id

The id.

System.Guid guid

The GUID based identifier.

System.String name

The name.

System.String description

The description.

System.Boolean isAvailable

if set to true it will be available in edit mode.

System.Int32 sortOrder

The sort order.

ContentType(Int32, Guid, String, String, Boolean, Int32, ContentTypeBase)

Initializes a new instance of the ContentType class.

Declaration
protected ContentType(int id, Guid guid, string name, string description, bool isAvailable, int sortOrder, ContentTypeBase contentTypeBase)
Parameters
Type Name Description
System.Int32 id

The id.

System.Guid guid

The GUID based identifier.

System.String name

The name.

System.String description

The description.

System.Boolean isAvailable

if set to true it will be available in edit mode.

System.Int32 sortOrder

The sort order.

ContentTypeBase contentTypeBase

The base for the content type

Properties

ACL

Gets or sets the AccessControlList for this content type.

Declaration
public AccessControlList ACL { get; set; }
Property Value
Type Description
AccessControlList
Remarks

The implementation for content types currently only respects the Create permission setting.

Base

NOTE: This is a pre-release API that is UNSTABLE and might not satisfy the compatibility requirements as denoted by its associated normal version. Gets or sets the base for this content type instance (e.g. page or block or etc).

Declaration
public ContentTypeBase Base { get; set; }
Property Value
Type Description
ContentTypeBase

Created

Gets the date this content type instance was created.

Declaration
public DateTime? Created { get; }
Property Value
Type Description
System.Nullable<System.DateTime>

DefaultMvcController

Gets or sets the Type of the "TemplateModel" that should be used as the default template used for web requests.

Declaration
public Type DefaultMvcController { get; set; }
Property Value
Type Description
System.Type
Remarks

The value is a MVC controller.

DefaultMvcPartialView

Gets or sets the Name of the MVC partial view "TemplateModel" that should be used as the default used for web requests.

Declaration
public string DefaultMvcPartialView { get; set; }
Property Value
Type Description
System.String
Remarks

The value is the name of a MVC partial view.

DefaultWebFormTemplate

Gets or sets the Type of the "TemplateModel" that should be used as the default template used for web requests.

Declaration
public Type DefaultWebFormTemplate { get; set; }
Property Value
Type Description
System.Type
Remarks

The value can either be a webform or a user control.

Description

Gets or sets the description of this content type instance.

Declaration
public string Description { get; set; }
Property Value
Type Description
System.String

DescriptionLocalizationFormat

Gets the description localization format.

Declaration
[Obsolete("Override the LocalizedDescription property if you want to change the localization key.")]
protected virtual string DescriptionLocalizationFormat { get; }
Property Value
Type Description
System.String
Remarks

The format that is used when localizing the Description in LocalizedDescription.

DisplayName

Gets or sets the diplay name of this content type instance.

Declaration
public string DisplayName { get; set; }
Property Value
Type Description
System.String
Remarks

This is the name for the content type in UI. When accessing the content type programatically Name should be used.

FullName

Gets the full name formed by group name between brackets and Name

Declaration
public string FullName { get; }
Property Value
Type Description
System.String

GroupName

Gets or sets the group name of this content type instance.

Declaration
public string GroupName { get; set; }
Property Value
Type Description
System.String
Remarks

This is added in brackets to the DisplayName in UI. Group names are not stored in the database, the value is only assigned from the typed model.

GroupNameLocalizationFormat

Gets the group name localization format.

Declaration
[Obsolete("Override the LocalizedGroupName property if you want to change the localization key.")]
protected virtual string GroupNameLocalizationFormat { get; }
Property Value
Type Description
System.String
Remarks

The format that is used when localizing the GroupName in LocalizedFullName.

GUID

Gets or sets the globally unique identifier for this content type instance.

Declaration
public Guid GUID { get; set; }
Property Value
Type Description
System.Guid

ID

Gets or sets the unique identifier for this content type instance.

Declaration
public int ID { get; set; }
Property Value
Type Description
System.Int32

IsAvailable

Gets or sets if the ContentType should be available in edit mode.

Declaration
public bool IsAvailable { get; set; }
Property Value
Type Description
System.Boolean

IsNew

Gets a value indicating whether this content type has been saved to the database.

Declaration
public bool IsNew { get; }
Property Value
Type Description
System.Boolean

true if this content type is new, i.e. not saved to the database; otherwise, false.

IsReadOnly

Gets a value indicating if current instance is read-only.

Declaration
public virtual bool IsReadOnly { get; protected set; }
Property Value
Type Description
System.Boolean

true if this instance is read-only; otherwise, false.

LocalizationService

The localization service used to resolve LocalizedName and LocalizedDescription.

Declaration
protected LocalizationService LocalizationService { get; set; }
Property Value
Type Description
LocalizationService

LocalizedDescription

Gets the description of this content type localized to current language. If no localized description exist the standard Description will be returned.

Declaration
public virtual string LocalizedDescription { get; }
Property Value
Type Description
System.String
Remarks

To localize the content type description it should be located at the language path "/contenttypes/[YourContentTypeName]/description", where YourContentTypeName matches the Name of the content type.

If the content type is part of a group, it can also be located at the language path "/contenttypes/[YourGroupName]/[YourContentTypeName]/description", where YourGroupName matches the GroupName of the content type.

LocalizedFullName

Gets the localized name of the content type including the group name if set.

Declaration
public virtual string LocalizedFullName { get; }
Property Value
Type Description
System.String
Remarks

This combines GroupName and Name in this format "[GroupName] Name".

LocalizedGroupName

Gets the localized group name.

Declaration
public virtual string LocalizedGroupName { get; }
Property Value
Type Description
System.String

LocalizedName

Gets the name of this content type localized to the current language. If no localized name exist the standard Name will be returned.

Declaration
public virtual string LocalizedName { get; }
Property Value
Type Description
System.String
Remarks

To localize the content type name it should be located at the language path "/contenttypes/[YourContentTypeName]/name", where YourContentTypeName matches the Name of the content type.

To localize the content type name it should be located at the language path "/contenttypes/[YourContentTypeName]/name", where YourContentTypeName matches the Name of the content type.

If the content type is part of a group, it can also be located at the language path "/contenttypes/[YourGroupName]/[YourContentTypeName]/name", where YourGroupName matches the GroupName of the content type.

ModelType

Gets the System.Type of the model used to represent this type.

Declaration
public Type ModelType { get; set; }
Property Value
Type Description
System.Type

ModelTypeString

Gets or sets the string format of the model type.

Declaration
public string ModelTypeString { get; set; }
Property Value
Type Description
System.String

The model type string.

Name

Gets or sets the name of this content type instance.

Declaration
public string Name { get; set; }
Property Value
Type Description
System.String

NameLocalizationFormat

Gets the name localization format.

Declaration
[Obsolete("Override the LocalizedName property if you want to change the localization key.")]
protected virtual string NameLocalizationFormat { get; }
Property Value
Type Description
System.String
Remarks

The format that is used when localizing the Name in LocalizedName.

PropertyDefinitions

Gets a PropertyDefinitionCollection containing all property definitions used by this content type.

Declaration
public PropertyDefinitionCollection PropertyDefinitions { get; }
Property Value
Type Description
PropertyDefinitionCollection
Remarks

The contents of this collection will not be persisted when the page or block that uses it is saved. If you want to work with property definitions, use the IPropertyDefinitionRepository.

Saved

Gets the date this content type instance was saved.

Declaration
public DateTime? Saved { get; }
Property Value
Type Description
System.Nullable<System.DateTime>

SavedBy

Gets who saved this content type instance.

Declaration
public string SavedBy { get; }
Property Value
Type Description
System.String

SortOrder

Gets or sets the default sort index based on other types

Declaration
public int SortOrder { get; set; }
Property Value
Type Description
System.Int32

Version

NOTE: This is a pre-release API that is UNSTABLE and might not satisfy the compatibility requirements as denoted by its associated normal version. Gets or sets the version of the content type.

Declaration
public Version Version { get; set; }
Property Value
Type Description
System.Version

Methods

CompareTo(Object)

Declaration
public int CompareTo(object obj)
Parameters
Type Name Description
System.Object obj
Returns
Type Description
System.Int32

CreateWritableClone()

Creates a writable clone of this object.

Declaration
public object CreateWritableClone()
Returns
Type Description
System.Object

A clone of this object that is writable.

CreateWritableCloneImplementation()

The method called by IReadOnly.CreateWritableClone.

Declaration
protected virtual object CreateWritableCloneImplementation()
Returns
Type Description
System.Object

A clone of this object that is writable.

Remarks

This method is called by CreateWritableClone(). If you are inheriting, directly or indirectly, from ContentType you should override this method to make sure that all reference type members of your class are cloned.

Your override of this method must create the clone by calling base.CreateWritableCloneImplementation(). This ensures that all classes in the inheritance chain can create clones as necessary. Also, by calling the base implementation the values of all value type members are copied as ContentType's implementation of this method calls System.Object.MemberwiseClone().

Equals(Object)

Determines whether this instance of ContentType and a specified object, which must also be a ContentType object, have the same value.

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj

An object.

Returns
Type Description
System.Boolean

true if obj is a ContentType and its value is the same as this instance; otherwise, false.

Overrides
System.Object.Equals(System.Object)

GetHashCode()

Returns the hash code for this ContentType.

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32

A 32-bit signed integer hash code.

Overrides
System.Object.GetHashCode()

MakeReadOnly()

Makes the current instance and all it's properties read-only.

Declaration
public virtual void MakeReadOnly()
Remarks

After calling this method the IsReadOnly property will return true.

ResetContentType()

Resets data that can be set from model.

Declaration
public virtual void ResetContentType()

ThrowIfReadOnly()

Throws an exception if the current instance is read-only.

Declaration
protected virtual void ThrowIfReadOnly()

Operators

Equality(ContentType, ContentType)

Determines whether two specified ContentType objects have the same value.

Declaration
public static bool operator ==(ContentType x, ContentType y)
Parameters
Type Name Description
ContentType x

A ContentType or a null reference.

ContentType y

A ContentType or a null reference.

Returns
Type Description
System.Boolean

true if the value of x is the same as the value of y; otherwise, false.

Inequality(ContentType, ContentType)

Determines whether two specified ContentType objects have different values.

Declaration
public static bool operator !=(ContentType x, ContentType y)
Parameters
Type Name Description
ContentType x

A ContentType or a null reference.

ContentType y

A ContentType or a null reference.

Returns
Type Description
System.Boolean

true if the value of x is different from the value of y; otherwise, false.

Explicit Interface Implementations

IComparable<ContentType>.CompareTo(ContentType)

Declaration
int IComparable<ContentType>.CompareTo(ContentType other)
Parameters
Type Name Description
ContentType other
Returns
Type Description
System.Int32

Implements

System.IComparable
System.IComparable<T>

Extension Methods