Class PropertyData
Abstract class that all properties inherit from.
Inheritance
Inherited Members
Namespace: EPiServer.Core
Assembly: EPiServer.dll
Version: 10.10.4Syntax
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
{
// ....
}
This property type will automatically be registered with EPiServer.
[PropertyDefinitionTypePlugIn]
public class PropertySpecialLink : PropertyString
{
// ....
}
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 |
|
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 |
|
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 |
|
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 |
|
IsNull
Check for null property (no value has been set).
Declaration
public virtual bool IsNull { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
IsPropertyData
If this property is a standard page property.
Declaration
public bool IsPropertyData { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
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 |
|
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]
public virtual LocalizationService LocalizationService { get; set; }
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
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
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")]
public static bool UseLegacyValueType { get; set; }
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. |
CreatePropertyControl()
Creates an IPropertyControl that is used to display a user interface for the property.
Declaration
[Obsolete("Use IPropertyControlFactory to cretate property controls")]
public virtual IPropertyControl CreatePropertyControl()
Returns
Type | Description |
---|---|
IPropertyControl | An IPropertyControl that is used to display a user interface for the property. |
Remarks
It is possible to change which control should be used by registering a different IPropertyControl for the PropertyData class in PropertyControlClassFactory.
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
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 '&'.
GetSetting(Type)
Gets a custom settings object if specified by either PropertyDefinition or PropertyControl.
Declaration
[Obsolete("This method does not support typed property settings. Use extension method myContent.GetPropertySettings<TinyMCESettings, PageWithPropertySettings>(p => p.MainBody) or PropertySettingsResolver to resolve property settings.")]
public IPropertySettings GetSetting(Type settingsType)
Parameters
Type | Name | Description |
---|---|---|
System.Type | settingsType | Type of the settings to return. |
Returns
Type | Description |
---|---|
IPropertySettings | a custom settings object |
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
public abstract 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
protected virtual bool RawPropertyRequiresTypeInformation()
Returns
Type | Description |
---|---|
System.Boolean |
ReplaceHtmlLinks(String, PropertyData.TranslateUri)
Replaces the HTML links.
Declaration
[Obsolete("This method is no longer in use and will be removed in a future release. It will not be replaced")]
public string ReplaceHtmlLinks(string html, PropertyData.TranslateUri translateUri)
Parameters
Type | Name | Description |
---|---|---|
System.String | html | The HTML. |
PropertyData.TranslateUri | translateUri | The translate URI. |
Returns
Type | Description |
---|---|
System.String | A string where the html links have been replaced. |
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
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
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
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 '&'.
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 |
TranslateDescription()
Translates the description to the current language.
Declaration
public virtual string TranslateDescription()
Returns
Type | Description |
---|---|
System.String | The translated description |
Remarks
If no translation is found the help text defined in the EPiServer.Core.PropertyData.PropertyDefinition will be used.
TranslateDisplayName()
Translates the display name to the current language.
Declaration
public virtual string TranslateDisplayName()
Returns
Type | Description |
---|---|
System.String | The translated display name. |
Remarks
If no translation is found the EditCaption defined in the EPiServer.Core.PropertyData.PropertyDefinition will be used.
Explicit Interface Implementations
IReadOnly.CreateWritableClone()
Creates writable clone of this object.
Declaration
object IReadOnly.CreateWritableClone()
Returns
Type | Description |
---|---|
System.Object | Writable clone object. |