Class Content
Represents a Content object
Namespace:System.Dynamic.ExpandoObject
Assembly:Umbraco.Core.dll
Syntax
[Serializable]
[DataContract(IsReference = true)]
public class Content : ContentBase, IContent, IContentBase, IUmbracoEntity, IAggregateRoot, IDeletableEntity, IEntity, IDeepCloneable, IRememberBeingDirty, ICanBeDirty
Constructors
Content(String, Int32, IContentType)
Constructor for creating a Content object
Declaration
public Content(string name, int parentId, IContentType contentType)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the content |
System.Int32 | parentId | Id of the Parent content |
IContentType | contentType | ContentType for the current Content object |
Content(String, Int32, IContentType, PropertyCollection)
Constructor for creating a Content object
Declaration
public Content(string name, int parentId, IContentType contentType, PropertyCollection properties)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the content |
System.Int32 | parentId | Id of the Parent content |
IContentType | contentType | ContentType for the current Content object |
PropertyCollection | properties | Collection of properties |
Content(String, IContent, IContentType)
Constructor for creating a Content object
Declaration
public Content(string name, IContent parent, IContentType contentType)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the content |
IContent | parent | Parent IContent object |
IContentType | contentType | ContentType for the current Content object |
Content(String, IContent, IContentType, PropertyCollection)
Constructor for creating a Content object
Declaration
public Content(string name, IContent parent, IContentType contentType, PropertyCollection properties)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the content |
IContent | parent | Parent IContent object |
IContentType | contentType | ContentType for the current Content object |
PropertyCollection | properties | Collection of properties |
Properties
ContentType
Gets the ContentType used by this content object
Declaration
[IgnoreDataMember]
public IContentType ContentType { get; }
Property Value
Type | Description |
---|---|
IContentType |
ExpireDate
The date this Content should expire and thus be unpublished
Declaration
[DataMember]
public DateTime? ExpireDate { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.DateTime> |
HasPublishedVersion
Gets a value indicating whether the content has a published version.
Declaration
public bool HasPublishedVersion { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsBlueprint
Declaration
[DataMember]
public bool IsBlueprint { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Language
Language of the data contained within this Content object.
Declaration
[Obsolete("This is not used and will be removed from the codebase in future versions")]
public string Language { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Published
Boolean indicating whether this Content is Published or not
Declaration
[DataMember]
public bool Published { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
Setting Published to true/false should be private or internal and should ONLY be used for wiring up the value from the db or modifying it based on changing the published state.
PublishedVersionGuid
Gets or sets the unique identifier of the published version, if any.
Declaration
[IgnoreDataMember]
public Guid PublishedVersionGuid { get; }
Property Value
Type | Description |
---|---|
System.Guid |
ReleaseDate
The date this Content should be released and thus be published
Declaration
[DataMember]
public DateTime? ReleaseDate { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.DateTime> |
Status
Gets the current status of the Content
Declaration
[IgnoreDataMember]
public ContentStatus Status { get; }
Property Value
Type | Description |
---|---|
ContentStatus |
Template
Gets or sets the template used by the Content. This is used to override the default one from the ContentType.
Declaration
[DataMember]
public virtual ITemplate Template { get; set; }
Property Value
Type | Description |
---|---|
ITemplate |
Remarks
If no template is explicitly set on the Content object, the Default template from the ContentType will be returned.
WriterId
Id of the user who wrote/updated this Content
Declaration
[DataMember]
public virtual int WriterId { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
ChangeContentType(IContentType)
Changes the ContentType for the current content object
Declaration
public void ChangeContentType(IContentType contentType)
Parameters
Type | Name | Description |
---|---|---|
IContentType | contentType | New ContentType for this content |
Remarks
Leaves PropertyTypes intact after change
ChangeContentType(IContentType, Boolean)
Changes the ContentType for the current content object and removes PropertyTypes, which are not part of the new ContentType.
Declaration
public void ChangeContentType(IContentType contentType, bool clearProperties)
Parameters
Type | Name | Description |
---|---|---|
IContentType | contentType | New ContentType for this content |
System.Boolean | clearProperties | Boolean indicating whether to clear PropertyTypes upon change |
ChangePublishedState(PublishedState)
Changes the Published state of the content object
Declaration
public void ChangePublishedState(PublishedState state)
Parameters
Type | Name | Description |
---|---|---|
PublishedState | state |
ChangeTrashedState(Boolean, Int32)
Changes the Trashed state of the content object
Declaration
public override void ChangeTrashedState(bool isTrashed, int parentId = -20)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | isTrashed | Boolean indicating whether content is trashed (true) or not trashed (false) |
System.Int32 | parentId |
Clone()
Creates a deep clone of the current entity with its identity and it's property identities reset
Declaration
[Obsolete("Use DeepCloneWithResetIdentities instead")]
public IContent Clone()
Returns
Type | Description |
---|---|
IContent |
DeepClone()
Declaration
public override object DeepClone()
Returns
Type | Description |
---|---|
System.Object |
DeepCloneWithResetIdentities()
Creates a deep clone of the current entity with its identity and it's property identities reset
Declaration
public IContent DeepCloneWithResetIdentities()
Returns
Type | Description |
---|---|
IContent |