Class ContentBase
Represents an abstract class for base Content properties and methods
Namespace: Umbraco.Cms.Core.Models
Assembly: Umbraco.Core.dll
Syntax
[DataContract(IsReference = true)]
public abstract class ContentBase : TreeEntityBase, IContentBase, IUmbracoEntity, ITreeEntity, IEntity, IDeepCloneable, IRememberBeingDirty, ICanBeDirty
Constructors
View SourceContentBase(String, Int32, IContentTypeComposition, IPropertyCollection, String)
Initializes a new instance of the ContentBase class.
Declaration
protected ContentBase(string name, int parentId, IContentTypeComposition contentType, IPropertyCollection properties, string culture = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | |
| System.Int32 | parentId | |
| IContentTypeComposition | contentType | |
| IPropertyCollection | properties | |
| System.String | culture |
ContentBase(String, IContentBase, IContentTypeComposition, IPropertyCollection, String)
Initializes a new instance of the ContentBase class.
Declaration
protected ContentBase(string name, IContentBase parent, IContentTypeComposition contentType, IPropertyCollection properties, string culture = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | |
| IContentBase | parent | |
| IContentTypeComposition | contentType | |
| IPropertyCollection | properties | |
| System.String | culture |
Properties
View SourceAvailableCultures
Gets the available cultures.
Declaration
public IEnumerable<string> AvailableCultures { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<System.String> |
Remarks
Cannot contain the invariant culture, which is always available.
ContentType
Declaration
[IgnoreDataMember]
public ISimpleContentType ContentType { get; }
Property Value
| Type | Description |
|---|---|
| ISimpleContentType |
ContentTypeId
Integer Id of the default ContentType
Declaration
[DataMember]
public int ContentTypeId { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
CultureInfos
Gets culture infos of the content item.
Declaration
[DataMember]
public ContentCultureInfosCollection CultureInfos { get; set; }
Property Value
| Type | Description |
|---|---|
| ContentCultureInfosCollection |
Remarks
Because a dictionary key cannot be null this cannot contain the invariant
culture name, which must be get or set via the Name property.
Properties
Gets or sets the collection of properties for the entity.
Declaration
[DataMember]
public IPropertyCollection Properties { get; set; }
Property Value
| Type | Description |
|---|---|
| IPropertyCollection |
Remarks
Marked DoNotClone since we'll manually clone the underlying field to deal with the event handling
VersionId
Declaration
[IgnoreDataMember]
public int VersionId { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
WriterId
Id of the user who wrote/updated this entity
Declaration
[DataMember]
public int WriterId { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Methods
View SourceChangeContentType(ISimpleContentType)
Declaration
public void ChangeContentType(ISimpleContentType contentType)
Parameters
| Type | Name | Description |
|---|---|---|
| ISimpleContentType | contentType |
GetCultureName(String)
Gets the name of the content item for a specified language.
Declaration
public string GetCultureName(string culture)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | culture |
Returns
| Type | Description |
|---|---|
| System.String |
Remarks
When culture is null, gets the invariant
culture name, which is the value of the Name property.
When culture is not null, and the content type
does not vary by culture, returns null.
GetDirtyProperties()
Gets properties that are dirty.
Declaration
public override IEnumerable<string> GetDirtyProperties()
Returns
| Type | Description |
|---|---|
| IEnumerable<System.String> |
Remarks
Overridden to include user properties.
GetUpdateDate(String)
Gets the date a culture was updated.
Declaration
public DateTime? GetUpdateDate(string culture)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | culture |
Returns
| Type | Description |
|---|---|
| System.Nullable<DateTime> |
Remarks
When culture is null, returns null.
If the specified culture is not available, returns null.
GetValue(String, String, String, Boolean)
Gets the value of a Property
Declaration
public object GetValue(string propertyTypeAlias, string culture = null, string segment = null, bool published = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | propertyTypeAlias | |
| System.String | culture | |
| System.String | segment | |
| System.Boolean | published |
Returns
| Type | Description |
|---|---|
| System.Object |
Remarks
Values 'null' and 'empty' are equivalent for culture and segment.
GetValue<TValue>(String, String, String, Boolean)
Gets the typed value of a Property
Declaration
public TValue GetValue<TValue>(string propertyTypeAlias, string culture = null, string segment = null, bool published = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | propertyTypeAlias | |
| System.String | culture | |
| System.String | segment | |
| System.Boolean | published |
Returns
| Type | Description |
|---|---|
| TValue |
Type Parameters
| Name | Description |
|---|---|
| TValue |
Remarks
Values 'null' and 'empty' are equivalent for culture and segment.
GetWereDirtyProperties()
Gets properties that were dirty.
Declaration
public override IEnumerable<string> GetWereDirtyProperties()
Returns
| Type | Description |
|---|---|
| IEnumerable<System.String> |
Remarks
Overridden to include user properties.
HasProperty(String)
Gets a value indicating whether the content entity has a property with the supplied alias.
Declaration
public bool HasProperty(string propertyTypeAlias)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | propertyTypeAlias |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Indicates that the content entity has a property with the supplied alias, but not necessarily that the content has a value for that property. Could be missing.
IsCultureAvailable(String)
Gets a value indicating whether a given culture is available.
Declaration
public bool IsCultureAvailable(string culture)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | culture |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
A culture becomes available whenever the content name for this culture is non-null, and it becomes unavailable whenever the content name is null.
Returns false for the invariant culture, in order to be consistent
with AvailableCultures, even though the invariant culture is
always available.
Does not support the '*' wildcard (returns false).
IsDirty()
Determines whether the current entity is dirty.
Declaration
public override bool IsDirty()
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Overridden to include user properties.
IsEntityDirty()
Gets a value indicating whether the current entity's own properties (not user) are dirty.
Declaration
public bool IsEntityDirty()
Returns
| Type | Description |
|---|---|
| System.Boolean |
IsPropertyDirty(String)
Determines whether a specific property is dirty.
Declaration
public override bool IsPropertyDirty(string propertyName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | propertyName |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Overridden to include user properties.
PerformDeepClone(Object)
Used by inheritors to modify the DeepCloning logic
Declaration
protected override void PerformDeepClone(object clone)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | clone |
Remarks
Overridden to deal with specific object instances
PropertiesChanged(Object, NotifyCollectionChangedEventArgs)
Declaration
protected void PropertiesChanged(object sender, NotifyCollectionChangedEventArgs e)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | sender | |
| System.Collections.Specialized.NotifyCollectionChangedEventArgs | e |
RemoveValue(String)
Removes a Property value.
Declaration
public void RemoveValue(string propertyTypeAlias)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | propertyTypeAlias | The alias of the property value to remove. |
Remarks
This removes the value for all cultures and segments.
ResetDirtyProperties(Boolean)
Resets dirty properties.
Declaration
public override void ResetDirtyProperties(bool rememberDirty)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | rememberDirty | A value indicating whether to remember dirty properties. |
Remarks
Overridden to include user properties.
ResetWereDirtyProperties()
Declaration
public override void ResetWereDirtyProperties()
SetCultureName(String, String)
Sets the name of the content item for a specified culture.
Declaration
public void SetCultureName(string name, string culture)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | |
| System.String | culture |
Remarks
When culture is null, sets the invariant
culture name, which sets the Name property.
When culture is not null, throws if the content
type does not vary by culture.
SetValue(String, Object, String, String)
Sets the (edited) value of a Property
Declaration
public void SetValue(string propertyTypeAlias, object value, string culture = null, string segment = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | propertyTypeAlias | |
| System.Object | value | |
| System.String | culture | |
| System.String | segment |
Remarks
Values 'null' and 'empty' are equivalent for culture and segment.
WasDirty()
Determines whether the current entity is dirty.
Declaration
public override bool WasDirty()
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Overridden to include user properties.
WasEntityDirty()
Gets a value indicating whether the current entity's own properties (not user) were dirty.
Declaration
public bool WasEntityDirty()
Returns
| Type | Description |
|---|---|
| System.Boolean |
WasPropertyDirty(String)
Determines whether a specific property was dirty.
Declaration
public override bool WasPropertyDirty(string propertyName)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | propertyName |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Overridden to include user properties.