Class PropertyData

Abstract class that all content properties inherit from.

Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Core
Assembly: EPiServer.dll
Version: 11.20.2
Syntax
public abstract class PropertyData : IReadOnly<PropertyData>, IReadOnly
Remarks

You can make your own properties and use them just as the built-in EPiServer properties. This is done by using PropertyDefinitionTypePlugInAttribute to automatically register the property data type.

Examples
  This property type will automatically be registered with EPiServer.
        [PropertyDefinitionTypePlugIn]
public class PropertySpecialLink : PropertyString
{
// ....
}

Constructors

PropertyData()

Initializes new instance

Declaration
protected PropertyData()

PropertyData(Boolean)

Initializes new instance

Declaration
protected PropertyData(bool isNull)
Parameters
Type Name Description
System.Boolean isNull

Defines if the property has a value or not. Used by inherited classes constructors.

Properties

DisplayEditUI

If the property should display an edit user interface.

Declaration
public virtual bool DisplayEditUI { get; set; }
Property Value
Type Description
System.Boolean

true if this property should display an edit user interface; otherwise, false.

FieldOrder

Which sort order is used when loading and displaying property data objects

Declaration
public int FieldOrder { get; set; }
Property Value
Type Description
System.Int32
Remarks

Used to sort properties for editing purposes.

IsDynamicProperty

Test if this property has been set by a dynamic property.

Declaration
public bool IsDynamicProperty { get; set; }
Property Value
Type Description
System.Boolean

true if this property is a dynamic property; otherwise, false.

IsLanguageSpecific

Test if this property is specific to a language in multilanguage configuration

Declaration
public virtual bool IsLanguageSpecific { get; set; }
Property Value
Type Description
System.Boolean

true if this instance is language specific; otherwise, false.

IsMetaData

Test if this property represents metadata or content type information.

Declaration
public bool IsMetaData { get; }
Property Value
Type Description
System.Boolean

True if this property is meta data.

IsModified

Check if property has been modified.

Declaration
public virtual bool IsModified { get; set; }
Property Value
Type Description
System.Boolean

true if this instance is modified; otherwise, false.

IsNull

Check for null property (no value has been set).

Declaration
public virtual bool IsNull { get; }
Property Value
Type Description
System.Boolean

true if this property is null; otherwise, false.

IsPropertyData

If this property is a standard page property.

Declaration
public bool IsPropertyData { get; set; }
Property Value
Type Description
System.Boolean

true if this instance is property data; otherwise, false.

Remarks

This simply determines that it is not a dynamic property and not meta data.

IsReadOnly

Gets and sets the read-only property.

Declaration
public bool IsReadOnly { get; protected set; }
Property Value
Type Description
System.Boolean

true if this property is read only; otherwise, false.

IsRequired

Check if the property value is required.

Declaration
public bool IsRequired { get; set; }
Property Value
Type Description
System.Boolean

LocalizationService

Gets or sets the LocalizationService used by the current PropertyData instance to retrieve localized texts.

Declaration
[EPiServerIgnoreDataMember]
[Obsolete("Use LocalizationService.Current")]
public virtual LocalizationService LocalizationService { get; }
Property Value
Type Description
LocalizationService

The current LocalizationService used internally.

Locate

Gets the object used to resolve services part of the public API.

Declaration
public ServiceLocationHelper Locate { get; }
Property Value
Type Description
ServiceLocationHelper

Name

The name of the property.

Declaration
public string Name { get; set; }
Property Value
Type Description
System.String

The name of the property.

OwnerTab

Which tab (i.e. edit mode group) the property belongs to.

Declaration
public int OwnerTab { get; set; }
Property Value
Type Description
System.Int32
Remarks

Used to group properties for editing purposes. See EditTab for a list of predifined tabs. If this value is set to a non-existing tab the property will not be rendered in EPiServers edit mode.

PageDefinitionID

Property definition for property, i e the page type specific identity of this property.

Declaration
[Obsolete("Use the property named PropertyDefinitionID instead", false)]
public virtual int PageDefinitionID { get; set; }
Property Value
Type Description
System.Int32

The identity (System.Int32) of this property definition.

Remarks

This property is only valid if IsMetaData is false.

Parent

Gets or sets the parent of this instance.

Declaration
public PropertyDataCollection Parent { get; set; }
Property Value
Type Description
PropertyDataCollection

The parent.

Remarks

A PropertyData instance usually belongs to a PropertyDataCollection which itself usually belongs to a PageData. This property is a back-link to the container PageDataCollection.

Note that null is a valid value for Parent.

PropertyDefinitionID

Property definition for property, i e the content type specific identity of this property.

Declaration
public virtual int PropertyDefinitionID { get; set; }
Property Value
Type Description
System.Int32

The identity (System.Int32) of this property definition.

Remarks

This property is only valid if IsMetaData is false.

PropertyValueType

Gets the System.Type of the property value.

Declaration
public abstract Type PropertyValueType { get; }
Property Value
Type Description
System.Type

The System.Type of the property value.

SettingsContainer

Gets the settings container which have all settings objects stored for this property.

Declaration
[Obsolete("Use extension method GetSettingsContainer() or IPropertyDataSettingsHelper")]
public PropertySettingsContainer SettingsContainer { get; }
Property Value
Type Description
PropertySettingsContainer

The settings container.

SettingsID

Gets or sets the settings ID used to load the settings container.

Declaration
[Obsolete("Use extension method GetSettingsID() or IPropertyDataSettingsHelper")]
public Guid SettingsID { get; }
Property Value
Type Description
System.Guid

The settings ID.

Type

Property type as defined by enum PropertyDataType.

Declaration
public abstract PropertyDataType Type { get; }
Property Value
Type Description
PropertyDataType

The type as defined by enum PropertyDataType.

UseLegacyValueType

For internal use, do not use. Sets whether some property classes should behave in a legacy way when returning their value.

Declaration
[Obsolete("Legacy value types are no longer supported", true)]
public static bool UseLegacyValueType { get; }
Property Value
Type Description
System.Boolean

Value

Gets or sets the value of the property.

Declaration
public abstract object Value { get; set; }
Property Value
Type Description
System.Object

The value of the property or null if the property has no value defined.

Methods

BuildRegularExpression(String[])

Creates a regular expression to be able to restore an array of html tags.

Declaration
protected string BuildRegularExpression(string[] safeTags)
Parameters
Type Name Description
System.String[] safeTags

The html tags that you want to appear as tags instead of encoded text.

Returns
Type Description
System.String

A regular expression to be able to restore an array of html tags.

Clear()

Clear value and set as null/undefined.

Declaration
public virtual void Clear()
Remarks

If the property is a required property, calling the Clear method will throw a RequiredPropertyValueException exception. Check IsRequired to see if this a required property.

Copy()

Creates a copy of this object.

Declaration
public virtual PropertyData Copy()
Returns
Type Description
PropertyData

A PropertyData object.

CreatePropertyDataObject(PropertyDataType)

Create the default PropertyData object for given base type.

Declaration
[Obsolete("Use PropertyDataFactory to create your PropertyData objects instead.", false)]
public static PropertyData CreatePropertyDataObject(PropertyDataType propType)
Parameters
Type Name Description
PropertyDataType propType

The PropertyDataType that you want to create a property for.

Returns
Type Description
PropertyData

CreatePropertyDataObject(RawProperty)

Creates a PropertyData object from a RawProperty.

Declaration
[Obsolete("No longer used, content are imported through IContentImporter and IPropertyImporter")]
public static PropertyData CreatePropertyDataObject(RawProperty rawProp)
Parameters
Type Name Description
RawProperty rawProp

The source to create the new property from.

Returns
Type Description
PropertyData

A new PropertyData object.

CreatePropertyDataObject(String, String)

Creates the property data object from the given typename and assembly, if the type is not found in the assembly fallback on a type matching the typeName in any loaded assembly.

Declaration
[Obsolete("Use PropertyDataFactory to create your PropertyData objects instead.", false)]
public static PropertyData CreatePropertyDataObject(string assemblyName, string typeName)
Parameters
Type Name Description
System.String assemblyName

Name of the assembly.

System.String typeName

Name of the type.

Returns
Type Description
PropertyData

A loaded PropertyData object.

CreateWritableClone()

Creates a writable clone of the property.

Declaration
public virtual PropertyData CreateWritableClone()
Returns
Type Description
PropertyData

A writable copy of the property.

EncodeForWebString(String)

Encodes a string to be displayed on a web page.

Declaration
protected virtual string EncodeForWebString(string stringValue)
Parameters
Type Name Description
System.String stringValue

The string value.

Returns
Type Description
System.String

A string where all html tags except those defined in 'EPiServer.Configuration.Settings.UISafeHtmlTags' have been encoded and therefore will appear in the text instead of tags.

Remarks

The character '& will also be encoded to '&amp;'.

GetValueOrDefault<T>()

Casts and returns the value of the property If the property is null, then the default value for T will be returned

Declaration
public T GetValueOrDefault<T>()
Returns
Type Description
T

The value of the property or default

Type Parameters
Name Description
T

The type to cast to

Remarks

The method performs a cast, it will not try to convert the value from one type to another. Meaning if the property value is not assignable to T a cast exception will be thrown

InitializeData(PropertyDataCollection)

Initialize any internal data. Called after loading the property's value but before setting it to read only.

Declaration
public virtual void InitializeData(PropertyDataCollection properties)
Parameters
Type Name Description
PropertyDataCollection properties

Current property collection.

Remarks

Put any database communication in this method.

IsEmptyValue(Object)

Called to determine if current value is considered empty.

Declaration
protected virtual bool IsEmptyValue(object value)
Parameters
Type Name Description
System.Object value
Returns
Type Description
System.Boolean
Remarks

Default implementation returns true for System.String.Empty

LoadData(Object)

Sets the internal representation from what is stored in the database. "Deserialize".

Declaration
public virtual void LoadData(object value)
Parameters
Type Name Description
System.Object value

The value.

MakeReadOnly()

Convert this property to ReadOnly

Declaration
public virtual void MakeReadOnly()
Remarks

Implementors should override this method when exposing complex objects that should be read-only as well.

Modified()

Make the property appear as modified.

Declaration
protected void Modified()

ModifiedNoCheck()

Sets the property as modified without first checking if the property is set to read only.

Declaration
protected void ModifiedNoCheck()

ParseToObject(String)

Creates a new instance of PropertyData with the given value, ie reversed ToString().

Declaration
[Obsolete("ParseToObject is no longer required to be implemented. The same functionality can be achieved by creating a new instance and calling the ParseToSelf method.")]
public virtual PropertyData ParseToObject(string value)
Parameters
Type Name Description
System.String value

The string value to parse.

Returns
Type Description
PropertyData

A new instance of PropertyData with the given value.

ParseToSelf(String)

Sets the value of the property from a string representation.

Declaration
public abstract void ParseToSelf(string value)
Parameters
Type Name Description
System.String value

The string value to parse.

QualifyAsNullString(String)

Help method to test if a string should be considered as a null value.

Declaration
public static bool QualifyAsNullString(string stringToCheck)
Parameters
Type Name Description
System.String stringToCheck

The string to check.

Returns
Type Description
System.Boolean
Remarks

Same as String.IsNullOrEmpty.

RawPropertyRequiresTypeInformation()

Declaration
[Obsolete("Method will no longer be called on Export. System properties are managed by Export internally.")]
protected virtual bool RawPropertyRequiresTypeInformation()
Returns
Type Description
System.Boolean

SaveData(PropertyDataCollection)

Return any internal data that will be stored to the database. "Serialize".

Declaration
public virtual object SaveData(PropertyDataCollection properties)
Parameters
Type Name Description
PropertyDataCollection properties

Current property collection.

Returns
Type Description
System.Object

The "serializable" value of the property.

SetDefaultValue()

Sets the default value for this property.

Declaration
protected abstract void SetDefaultValue()

SetPropertyValue(Object, SetPropertyValueDelegate)

Sets the property value.

Declaration
protected void SetPropertyValue(object value, SetPropertyValueDelegate doSet)
Parameters
Type Name Description
System.Object value

The value to set. Null will clear the value.

SetPropertyValueDelegate doSet

The SetPropertyValueDelegate that is responsible to set the value to the specific type.

ThrowIfReadOnly()

Checks if the property is read-only

Declaration
protected void ThrowIfReadOnly()

ToRawProperty()

Converts the current instance to a raw property.

Declaration
[Obsolete("Method will no longer be called on Export. Implement IPropertyExportTransform to control individual property types.")]
public RawProperty ToRawProperty()
Returns
Type Description
RawProperty

The initialized RawProperty.

ToRawString()

Gets the string representation of the "raw" data as it is represented externally in the database and in export packages.

Declaration
[Obsolete("Method will no longer be called on Export. Implement IPropertyExportTransform if the property need to be transformed on export.")]
public virtual string ToRawString()
Returns
Type Description
System.String

An external string representation of the property value.

Remarks

The internal data format is an storage detail and is not guaranteed to follow semantic versioning.

ToString()

Get the property's values display string.

Declaration
public override string ToString()
Returns
Type Description
System.String
Overrides
System.Object.ToString()

ToString(CultureInfo)

Get the property's values display string.

Declaration
public virtual string ToString(CultureInfo culture)
Parameters
Type Name Description
System.Globalization.CultureInfo culture
Returns
Type Description
System.String

ToWebString()

Get the web string representation of the property's value, on properties that do not use the editor this string will not contain any markup characters.

Declaration
public virtual string ToWebString()
Returns
Type Description
System.String

A string where all html tags except those defined in 'EPiServer.Configuration.Settings.UISafeHtmlTags' have been encoded and therefore will appear in the text instead of tags.

Remarks

The character '& will also be encoded to '&amp;'.

Translate(String)

Translate the given key.

Declaration
public static string Translate(string key)
Parameters
Type Name Description
System.String key

The string to translate.

Returns
Type Description
System.String

Explicit Interface Implementations

IReadOnly.CreateWritableClone()

Creates writable clone of this object.

Declaration
object IReadOnly.CreateWritableClone()
Returns
Type Description
System.Object

Writable clone object.

Implements

Extension Methods

EPiServer.Core.PropertyDataExtensions.TranslateDisplayName(EPiServer.Core.PropertyData)
EPiServer.Core.PropertyDataExtensions.TranslateDescription(EPiServer.Core.PropertyData)