Class ContentData
Base class for classes that holds content.
Inherited Members
Namespace: EPiServer.Core
Assembly: EPiServer.dll
Version: 7.19.2Syntax
public abstract class ContentData : IContentData, IInitializableContent, IModifiedTrackable, IReadOnly
Constructors
ContentData()
Initializes a new instance of the Content
Declaration
protected ContentData()
ContentData(PropertyDataCollection)
Initializes a new instance of the Content
Declaration
protected ContentData(PropertyDataCollection properties)
Parameters
Type | Name | Description |
---|---|---|
Property |
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. |
|
IsReadOnly
Gets a value indicating if current instance is read-only.
Declaration
public virtual bool IsReadOnly { get; protected set; }
Property Value
Type | Description |
---|---|
System. |
|
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. |
index |
Property Value
Type | Description |
---|---|
System. |
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 Link
To get data guaranteed to belong to this page, use the Get
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 |
---|---|
EPi |
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 |
---|---|
Property |
A collection with all properties defined for this ContentData, and all values. |
Remarks
By using the indexer of the Property
On Page
Methods
CreateWritableClone()
Creates a writable clone of this object.
Declaration
public object CreateWritableClone()
Returns
Type | Description |
---|---|
System. |
A clone of this object that is writable. |
Remarks
Any changes should be added by overriding Create
CreateWriteableCloneImplementation()
Creates a writable clone of this object.
Declaration
protected virtual object CreateWriteableCloneImplementation()
Returns
Type | Description |
---|---|
System. |
A clone of this object that is writable. |
Remarks
This method is called by Create
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 Content
GetValue(String)
Gets the value.
Declaration
public virtual object GetValue(string name)
Parameters
Type | Name | Description |
---|---|---|
System. |
name | The name of the property. |
Returns
Type | Description |
---|---|
System. |
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 Istrue
.
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 |
---|---|---|
Content |
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. |
index | The index. |
System. |
value | The value. |
Exceptions
Type | Condition |
---|---|
EPi |
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. |
|
IModifiedTrackable.ResetModified()
Resets the modified flag on all the properties in the Property collection.
Declaration
void IModifiedTrackable.ResetModified()