Class ContentData
Base class for classes that holds content.
Inherited Members
Namespace: EPiServer.Core
Assembly: EPiServer.dll
Version: 11.20.7Syntax
public abstract class ContentData : IContentData, IInitializableContent, IModifiedTrackable, IReadOnly
Constructors
ContentData()
Initializes a new instance of the ContentData class.
Declaration
protected ContentData()
ContentData(PropertyDataCollection)
Initializes a new instance of the ContentData class with the given property collection.
Declaration
protected ContentData(PropertyDataCollection properties)
Parameters
Type | Name | Description |
---|---|---|
PropertyDataCollection | properties | The collection of properties that the instance should contain. |
Properties
IsModified
Gets a value indicating whether this instance has been modified after loading.
Declaration
protected virtual bool IsModified { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
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 |
|
Item[String]
Gets or sets the value of a property in the Property collection or null if the property does not exist.
Declaration
public virtual object this[string index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.String | index |
Property Value
Type | Description |
---|---|
System.Object | The value of the page property which name matches the given index. |
Remarks
Note that this indexer will use the Pre and Post handlers for property lookup, i.e. the returned values are not guaranteed to belong to the page, but may be from a different source link dynamic properties or another page when LinkType is set to the value of FetchData.
To get data guaranteed to belong to this page, use the GetValue(String) and SetValue(String, Object) methods.
Also note that setting values with this indexer will only set values that acually belong to the page, i.e. you may get a valid value by reading from the indexer, but trying to set a new value for the same index may yield an exception if the value does not exist in the page.
Exceptions
Type | Condition |
---|---|
EPiServerException | Thrown if the property referenced by index does not exist. |
Property
Gets or sets the properties for this ContentData.
Declaration
[EPiServerIgnoreDataMember]
public virtual PropertyDataCollection Property { get; protected set; }
Property Value
Type | Description |
---|---|
PropertyDataCollection | A collection with all properties defined for this ContentData, and all values. |
Remarks
By using the indexer of the PropertyDataCollection you can get access to the PropertyData object. This will return null if the property is not found.
On PageData there is a list of default properties, see MetaDataProperties.
Methods
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. |
Remarks
Any changes should be added by overriding CreateWriteableCloneImplementation().
CreateWriteableCloneImplementation()
Creates a writable clone of this object.
Declaration
protected virtual object CreateWriteableCloneImplementation()
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 ContentData 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 the ContentData implementation of this method calls System.Object.MemberwiseClone().
GetValue(String)
Gets the value.
Declaration
public virtual object GetValue(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the property. |
Returns
Type | Description |
---|---|
System.Object | The value of the property data indexed by name. |
Remarks
This method can be used in the same way as the string indexer, but GetValue will not make use of the Pre and Post handlers. Any non-null value returned by GetValue is guaranteed to come from the PageData itself.
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
.
ResetModified()
Resets the modified flag on all the properties in the Property collection.
Declaration
protected virtual void ResetModified()
SetDefaultValues(ContentType)
Sets the default property values on the content data.
Declaration
public virtual void SetDefaultValues(ContentType contentType)
Parameters
Type | Name | Description |
---|---|---|
ContentType | contentType | Type of the content. |
Remarks
Override this method if you want to set custom default values.
SetValue(String, Object)
Sets the value.
Declaration
public virtual void SetValue(string index, object value)
Parameters
Type | Name | Description |
---|---|---|
System.String | index | The index. |
System.Object | value | The value. |
Exceptions
Type | Condition |
---|---|
EPiServerException | Thrown if the property referenced by index does not exist. |
ThrowIfReadOnly()
Throws an exception if the current instance is read-only.
Declaration
protected virtual void ThrowIfReadOnly()
Explicit Interface Implementations
IModifiedTrackable.IsModified
Gets a value indicating whether this instance has been modified after loading.
Declaration
bool IModifiedTrackable.IsModified { get; }
Returns
Type | Description |
---|---|
System.Boolean |
|
IModifiedTrackable.ResetModified()
Resets the modified flag on all the properties in the Property collection.
Declaration
void IModifiedTrackable.ResetModified()