Class ContentTypeBase
Represents an abstract class for base ContentType properties and methods
Namespace: Umbraco.Core.Models
Assembly: Umbraco.Core.dll
Syntax
[Serializable]
[DataContract(IsReference = true)]
public abstract class ContentTypeBase : TreeEntityBase, IContentTypeBase, IUmbracoEntity, ITreeEntity, IEntity, IDeepCloneable, IRememberBeingDirty, ICanBeDirty
Constructors
View SourceContentTypeBase(Int32)
Declaration
protected ContentTypeBase(int parentId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | parentId |
ContentTypeBase(IContentTypeBase)
Declaration
protected ContentTypeBase(IContentTypeBase parent)
Parameters
Type | Name | Description |
---|---|---|
IContentTypeBase | parent |
ContentTypeBase(IContentTypeBase, String)
Declaration
protected ContentTypeBase(IContentTypeBase parent, string alias)
Parameters
Type | Name | Description |
---|---|---|
IContentTypeBase | parent | |
System.String | alias |
Properties
View SourceAlias
The Alias of the ContentType
Declaration
[DataMember]
public virtual string Alias { get; set; }
Property Value
Type | Description |
---|---|
System.String |
AllowedAsRoot
Gets or Sets a boolean indicating whether this ContentType is allowed at the root
Declaration
[DataMember]
public bool AllowedAsRoot { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
AllowedContentTypes
Gets or sets a list of integer Ids for allowed ContentTypes
Declaration
[DataMember]
public IEnumerable<ContentTypeSort> AllowedContentTypes { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ContentTypeSort> |
Description
Description for the ContentType
Declaration
[DataMember]
public string Description { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Icon
Name of the icon (sprite class) used to identify the ContentType
Declaration
[DataMember]
public string Icon { get; set; }
Property Value
Type | Description |
---|---|
System.String |
IsContainer
Gets or Sets a boolean indicating whether this ContentType is a Container
Declaration
[DataMember]
public bool IsContainer { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
ContentType Containers doesn't show children in the tree, but rather in grid-type view.
IsElement
Gets or sets a value indicating whether this content type is for an element.
Declaration
[DataMember]
public bool IsElement { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
By default a content type is for a true media, member or document, but it can also be for an element, ie a subset that can for instance be used in nested content.
NoGroupPropertyTypes
Gets or sets the local property types that do not belong to a group.
Declaration
public IEnumerable<PropertyType> NoGroupPropertyTypes { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<PropertyType> |
PropertyGroups
Gets or sets the local property groups.
Declaration
[DataMember]
public PropertyGroupCollection PropertyGroups { get; set; }
Property Value
Type | Description |
---|---|
PropertyGroupCollection |
Remarks
A PropertyGroup corresponds to a Tab in the UI
Marked DoNotClone because we will manually deal with cloning and the event handlers
PropertyTypes
Gets all local property types all local property groups or ungrouped.
Declaration
[IgnoreDataMember]
public IEnumerable<PropertyType> PropertyTypes { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<PropertyType> |
SupportsPublishing
Gets a value indicating whether the content type supports publishing.
Declaration
public abstract bool SupportsPublishing { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
A publishing content type supports draft and published values for properties. It is possible to retrieve either the draft (default) or published value of a property. Setting the value always sets the draft value, which then needs to be published.
A non-publishing content type only supports one value for properties. Getting the draft or published value of a property returns the same thing, and publishing a value property has no effect.
Thumbnail
Name of the thumbnail used to identify the ContentType
Declaration
[DataMember]
public string Thumbnail { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Variations
Gets or sets the content variation of the content type.
Declaration
public virtual ContentVariation Variations { get; set; }
Property Value
Type | Description |
---|---|
ContentVariation |
Methods
View SourceAddPropertyGroup(String)
Adds a property group with the alias based on the specified groupName
.
Declaration
[Obsolete("Use AddPropertyGroup(name, alias) instead to explicitly set the alias.")]
public abstract bool AddPropertyGroup(string groupName)
Parameters
Type | Name | Description |
---|---|---|
System.String | groupName | Name of the group. |
Returns
Type | Description |
---|---|
System.Boolean | Returns |
Remarks
This method will also check if a group already exists with the same alias.
AddPropertyGroup(String, String)
Adds a property group with the specified name
and alias
.
Declaration
public abstract bool AddPropertyGroup(string alias, string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | alias | The alias. |
System.String | name | Name of the group. |
Returns
Type | Description |
---|---|
System.Boolean | Returns |
Remarks
This method will also check if a group already exists with the same alias.
AddPropertyType(PropertyType)
Adds a PropertyType, which does not belong to a PropertyGroup.
Declaration
public bool AddPropertyType(PropertyType propertyType)
Parameters
Type | Name | Description |
---|---|---|
PropertyType | propertyType | PropertyType to add |
Returns
Type | Description |
---|---|
System.Boolean | Returns |
AddPropertyType(PropertyType, String)
Adds the property type to the specified property group (creates a new group if not found).
Declaration
[Obsolete("Use AddPropertyType(propertyType, groupAlias, groupName) instead to explicitly set the alias of the group (note the slighty different parameter order).")]
public abstract bool AddPropertyType(PropertyType propertyType, string propertyGroupName)
Parameters
Type | Name | Description |
---|---|---|
PropertyType | propertyType | The property type to add. |
System.String | propertyGroupName | The name of the property group to add the property type to. |
Returns
Type | Description |
---|---|
System.Boolean | Returns |
AddPropertyType(PropertyType, String, String)
Adds the property type to the specified property group (creates a new group if not found and a name is specified).
Declaration
public abstract bool AddPropertyType(PropertyType propertyType, string groupAlias, string groupName)
Parameters
Type | Name | Description |
---|---|---|
PropertyType | propertyType | The property type to add. |
System.String | groupAlias | The alias of the property group to add the property type to. |
System.String | groupName | The name of the property group to create when not found. |
Returns
Type | Description |
---|---|
System.Boolean | Returns |
DeepCloneWithResetIdentities(String)
Declaration
public ContentTypeBase DeepCloneWithResetIdentities(string alias)
Parameters
Type | Name | Description |
---|---|---|
System.String | alias |
Returns
Type | Description |
---|---|
ContentTypeBase |
IsDirty()
Indicates whether the current entity is dirty.
Declaration
public override bool IsDirty()
Returns
Type | Description |
---|---|
System.Boolean | True if entity is dirty, otherwise False |
MovePropertyType(String, String)
Moves a PropertyType to a specified PropertyGroup
Declaration
public bool MovePropertyType(string propertyTypeAlias, string propertyGroupName)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyTypeAlias | Alias of the PropertyType to move |
System.String | propertyGroupName | Name of the PropertyGroup to move the PropertyType to |
Returns
Type | Description |
---|---|
System.Boolean |
Remarks
If propertyGroupName
is null then the property is moved back to
"generic properties" ie does not have a tab anymore.
PerformDeepClone(Object)
Declaration
protected override void PerformDeepClone(object clone)
Parameters
Type | Name | Description |
---|---|---|
System.Object | clone |
PropertyGroupsChanged(Object, NotifyCollectionChangedEventArgs)
Declaration
protected void PropertyGroupsChanged(object sender, NotifyCollectionChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | |
System.Collections.Specialized.NotifyCollectionChangedEventArgs | e |
PropertyTypeExists(String)
Checks whether a PropertyType with a given alias already exists
Declaration
public abstract bool PropertyTypeExists(string propertyTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyTypeAlias | Alias of the PropertyType |
Returns
Type | Description |
---|---|
System.Boolean | Returns |
PropertyTypesChanged(Object, NotifyCollectionChangedEventArgs)
Declaration
protected void PropertyTypesChanged(object sender, NotifyCollectionChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | |
System.Collections.Specialized.NotifyCollectionChangedEventArgs | e |
RemovePropertyGroup(String)
Removes a PropertyGroup from the current ContentType
Declaration
public void RemovePropertyGroup(string propertyGroupName)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyGroupName | Name of the PropertyGroup to remove |
RemovePropertyType(String)
Removes a PropertyType from the current ContentType
Declaration
public void RemovePropertyType(string propertyTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyTypeAlias | Alias of the PropertyType to remove |
ResetDirtyProperties()
Resets dirty properties by clearing the dictionary used to track changes.
Declaration
public override void ResetDirtyProperties()
Remarks
Please note that resetting the dirty properties could potentially obstruct the saving of a new or updated entity.
SupportsPropertyVariation(String, String, Boolean)
Validates that a combination of culture and segment is valid for the content type properties.
Declaration
public bool SupportsPropertyVariation(string culture, string segment, bool wildcards = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | culture | The culture. |
System.String | segment | The segment. |
System.Boolean | wildcards | A value indicating whether wildcard are supported. |
Returns
Type | Description |
---|---|
System.Boolean | True if the combination is valid; otherwise false. |
Remarks
The combination must be valid for properties of the content type. For instance, if the content type varies by culture, then an invariant culture is valid, because some properties may be invariant. On the other hand, if the content type is invariant, then a variant culture is invalid, because no property could possibly vary by culture.
SupportsVariation(String, String, Boolean)
Validates that a combination of culture and segment is valid for the content type.
Declaration
public bool SupportsVariation(string culture, string segment, bool wildcards = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | culture | The culture. |
System.String | segment | The segment. |
System.Boolean | wildcards | A value indicating whether wildcard are supported. |
Returns
Type | Description |
---|---|
System.Boolean | True if the combination is valid; otherwise false. |
Remarks
The combination must match the content type variation exactly. For instance, if the content type varies by culture, then an invariant culture would be invalid.
ToSimple()
Declaration
public abstract ISimpleContentType ToSimple()
Returns
Type | Description |
---|---|
ISimpleContentType |