Class ContentBase
Represents an abstract class for base Content properties and methods
Namespace:System.Dynamic.ExpandoObject
Assembly:Umbraco.Core.dll
Syntax
[Serializable]
[DataContract(IsReference = true)]
public abstract class ContentBase : Entity, IContentBase, IUmbracoEntity, IAggregateRoot, IDeletableEntity, IEntity, IDeepCloneable, IRememberBeingDirty, ICanBeDirty
Constructors
ContentBase(String, Int32, IContentTypeComposition, PropertyCollection)
Protected constructor for ContentBase (Base for Content and Media)
Declaration
protected ContentBase(string name, int parentId, IContentTypeComposition contentType, PropertyCollection properties)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Localized Name of the entity |
System.Int32 | parentId | |
IContentTypeComposition | contentType | |
PropertyCollection | properties |
ContentBase(String, IContentBase, IContentTypeComposition, PropertyCollection)
Protected constructor for ContentBase (Base for Content and Media)
Declaration
protected ContentBase(string name, IContentBase parent, IContentTypeComposition contentType, PropertyCollection properties)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Localized Name of the entity |
IContentBase | parent | |
IContentTypeComposition | contentType | |
PropertyCollection | properties |
Fields
ContentTypeBase
Declaration
protected IContentTypeComposition ContentTypeBase
Field Value
Type | Description |
---|---|
IContentTypeComposition |
Properties
ContentTypeId
Integer Id of the default ContentType
Declaration
[DataMember]
public virtual int ContentTypeId { get; protected set; }
Property Value
Type | Description |
---|---|
System.Int32 |
CreatorId
Profile of the user who created this Content
Declaration
[DataMember]
public virtual int CreatorId { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Level
Gets or sets the level of the content entity
Declaration
[DataMember]
public virtual int Level { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Name
Gets or sets the name of the entity
Declaration
[DataMember]
public virtual string Name { get; set; }
Property Value
Type | Description |
---|---|
System.String |
ParentId
Gets or sets the Id of the Parent entity
Declaration
[DataMember]
public virtual int ParentId { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Path
Gets or sets the path
Declaration
[DataMember]
public virtual string Path { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Properties
Collection of properties, which make up all the data available for this Content object
Declaration
[DataMember]
public virtual PropertyCollection Properties { get; set; }
Property Value
Type | Description |
---|---|
PropertyCollection |
PropertyGroups
List of PropertyGroups available on this Content object
Declaration
[IgnoreDataMember]
public IEnumerable<PropertyGroup> PropertyGroups { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<PropertyGroup> |
PropertyTypes
List of PropertyTypes available on this Content object
Declaration
[IgnoreDataMember]
public IEnumerable<PropertyType> PropertyTypes { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<PropertyType> |
SortOrder
Gets or sets the sort order of the content entity
Declaration
[DataMember]
public virtual int SortOrder { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Trashed
Boolean indicating whether this Content is Trashed or not. If Content is Trashed it will be located in the Recyclebin.
Declaration
[DataMember]
public virtual bool Trashed { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
When content is trashed it should be unpublished
Version
Guid Id of the curent Version
Declaration
[DataMember]
public Guid Version { get; }
Property Value
Type | Description |
---|---|
System.Guid |
Methods
ChangeTrashedState(Boolean, Int32)
Declaration
public abstract void ChangeTrashedState(bool isTrashed, int parentId = -20)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | isTrashed | |
System.Int32 | parentId |
GetDirtyProperties()
Returns both instance dirty properties and property type properties
Declaration
public override IEnumerable<string> GetDirtyProperties()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> |
GetValue(String)
Gets the value of a Property
Declaration
public virtual object GetValue(string propertyTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyTypeAlias | Alias of the PropertyType |
Returns
Type | Description |
---|---|
System.Object | Property Value as an System.Object |
GetValue<TPassType>(String)
Gets the value of a Property
Declaration
public virtual TPassType GetValue<TPassType>(string propertyTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyTypeAlias | Alias of the PropertyType |
Returns
Type | Description |
---|---|
TPassType | Property Value as a |
Type Parameters
Name | Description |
---|---|
TPassType | Type of the value to return |
HasProperty(String)
Indicates whether the content object has a property with the supplied alias
Declaration
public virtual bool HasProperty(string propertyTypeAlias)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyTypeAlias | Alias of the PropertyType |
Returns
Type | Description |
---|---|
System.Boolean | True if Property with given alias exists, otherwise False |
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 |
IsEntityDirty()
Returns true if only the entity properties are dirty
Declaration
public bool IsEntityDirty()
Returns
Type | Description |
---|---|
System.Boolean |
IsPropertyDirty(String)
Indicates whether a specific property on the current IContent entity is dirty.
Declaration
public override bool IsPropertyDirty(string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyName | Name of the property to check |
Returns
Type | Description |
---|---|
System.Boolean | True if any of the class properties are dirty or True if any of the user defined PropertyType properties are dirty based on their alias, otherwise False |
IsValid()
Boolean indicating whether the content and its properties are valid
Declaration
public virtual bool IsValid()
Returns
Type | Description |
---|---|
System.Boolean | True if content is valid otherwise false |
PropertiesChanged(Object, NotifyCollectionChangedEventArgs)
Declaration
protected void PropertiesChanged(object sender, NotifyCollectionChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | |
System.Collections.Specialized.NotifyCollectionChangedEventArgs | e |
ResetDirtyProperties(Boolean)
We will override this method to ensure that when we reset the dirty properties that we also reset the dirty changes made to the content's Properties (user defined)
Declaration
public override void ResetDirtyProperties(bool rememberPreviouslyChangedProperties)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | rememberPreviouslyChangedProperties |
SetPropertyValue(String, Boolean)
Sets the System.Boolean value of a Property
Declaration
public virtual void SetPropertyValue(string propertyTypeAlias, bool value)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyTypeAlias | Alias of the PropertyType |
System.Boolean | value | Value to set for the Property |
SetPropertyValue(String, DateTime)
Sets the System.DateTime value of a Property
Declaration
public virtual void SetPropertyValue(string propertyTypeAlias, DateTime value)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyTypeAlias | Alias of the PropertyType |
System.DateTime | value | Value to set for the Property |
SetPropertyValue(String, Decimal)
Sets the System.Decimal value of a Property
Declaration
public virtual void SetPropertyValue(string propertyTypeAlias, decimal value)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyTypeAlias | Alias of the PropertyType |
System.Decimal | value | Value to set for the Property |
SetPropertyValue(String, Double)
Sets the System.Double value of a Property
Declaration
public virtual void SetPropertyValue(string propertyTypeAlias, double value)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyTypeAlias | Alias of the PropertyType |
System.Double | value | Value to set for the Property |
SetPropertyValue(String, Int32)
Sets the System.Int32 value of a Property
Declaration
public virtual void SetPropertyValue(string propertyTypeAlias, int value)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyTypeAlias | Alias of the PropertyType |
System.Int32 | value | Value to set for the Property |
SetPropertyValue(String, Int64)
Sets the System.Int64 value of a Property
Declaration
public virtual void SetPropertyValue(string propertyTypeAlias, long value)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyTypeAlias | Alias of the PropertyType |
System.Int64 | value | Value to set for the Property |
SetPropertyValue(String, String)
Sets the System.String value of a Property
Declaration
public virtual void SetPropertyValue(string propertyTypeAlias, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyTypeAlias | Alias of the PropertyType |
System.String | value | Value to set for the Property |
SetPropertyValue(String, HttpPostedFile)
Sets the System.Web.HttpPostedFile value of a Property
Declaration
public virtual void SetPropertyValue(string propertyTypeAlias, HttpPostedFile value)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyTypeAlias | Alias of the PropertyType |
System.Web.HttpPostedFile | value | Value to set for the Property |
SetPropertyValue(String, HttpPostedFileBase)
Sets the System.Web.HttpPostedFileBase value of a Property
Declaration
public virtual void SetPropertyValue(string propertyTypeAlias, HttpPostedFileBase value)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyTypeAlias | Alias of the PropertyType |
System.Web.HttpPostedFileBase | value | Value to set for the Property |
SetPropertyValue(String, HttpPostedFileWrapper)
Sets the System.Web.HttpPostedFileWrapper value of a Property
Declaration
[Obsolete("There is no reason for this overload since HttpPostedFileWrapper inherits from HttpPostedFileBase")]
public virtual void SetPropertyValue(string propertyTypeAlias, HttpPostedFileWrapper value)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyTypeAlias | Alias of the PropertyType |
System.Web.HttpPostedFileWrapper | value | Value to set for the Property |
SetValue(String, Object)
Sets the System.Object value of a Property
Declaration
public virtual void SetValue(string propertyTypeAlias, object value)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyTypeAlias | Alias of the PropertyType |
System.Object | value | Value to set for the Property |
WasDirty()
Indicates whether the current entity was dirty.
Declaration
public override bool WasDirty()
Returns
Type | Description |
---|---|
System.Boolean | True if entity was dirty, otherwise False |
WasEntityDirty()
Returns true if only the entity properties were dirty
Declaration
public bool WasEntityDirty()
Returns
Type | Description |
---|---|
System.Boolean |
WasPropertyDirty(String)
Indicates whether a specific property on the current entity was changed and the changes were committed
Declaration
public override bool WasPropertyDirty(string propertyName)
Parameters
Type | Name | Description |
---|---|---|
System.String | propertyName | Name of the property to check |
Returns
Type | Description |
---|---|
System.Boolean | True if any of the class properties are dirty or True if any of the user defined PropertyType properties are dirty based on their alias, otherwise False |
Explicit Interface Implementations
IUmbracoEntity.AdditionalData
Some entities may expose additional data that other's might not, this custom data will be available in this collection
Declaration
IDictionary<string, object> IUmbracoEntity.AdditionalData { get; }
Returns
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, System.Object> |