Class DataValueEditor
Represents a value editor.
Inheritance
Namespace: Umbraco.Cms.Core.PropertyEditors
Assembly: Umbraco.Core.dll
Syntax
[DataContract]
public class DataValueEditor : IDataValueEditor
Constructors
View SourceDataValueEditor(ILocalizedTextService, IShortStringHelper, IJsonSerializer)
Initializes a new instance of the DataValueEditor class.
Declaration
public DataValueEditor(ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IJsonSerializer jsonSerializer)
Parameters
Type | Name | Description |
---|---|---|
ILocalizedTextService | localizedTextService | |
IShortStringHelper | shortStringHelper | |
IJsonSerializer | jsonSerializer |
DataValueEditor(ILocalizedTextService, IShortStringHelper, IJsonSerializer, IIOHelper, DataEditorAttribute)
Initializes a new instance of the DataValueEditor class.
Declaration
public DataValueEditor(ILocalizedTextService localizedTextService, IShortStringHelper shortStringHelper, IJsonSerializer jsonSerializer, IIOHelper ioHelper, DataEditorAttribute attribute)
Parameters
Type | Name | Description |
---|---|---|
ILocalizedTextService | localizedTextService | |
IShortStringHelper | shortStringHelper | |
IJsonSerializer | jsonSerializer | |
IIOHelper | ioHelper | |
DataEditorAttribute | attribute |
Properties
View SourceConfiguration
Gets or sets the value editor configuration.
Declaration
public virtual object Configuration { get; set; }
Property Value
Type | Description |
---|---|
System.Object |
FormatValidator
Gets the validator used to validate the special property type -level "format".
Declaration
public virtual IValueFormatValidator FormatValidator { get; }
Property Value
Type | Description |
---|---|
IValueFormatValidator |
HideLabel
If this is true than the editor will be displayed full width without a label
Declaration
[DataMember(Name = "hideLabel")]
public bool HideLabel { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsReadOnly
Set this to true if the property editor is for display purposes only
Declaration
public virtual bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
RequiredValidator
Gets the validator used to validate the special property type -level "required".
Declaration
public virtual IValueRequiredValidator RequiredValidator { get; }
Property Value
Type | Description |
---|---|
IValueRequiredValidator |
SupportsReadOnly
Declaration
public bool SupportsReadOnly { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Validators
A collection of validators for the pre value editor
Declaration
[DataMember(Name = "validation")]
public List<IValueValidator> Validators { get; }
Property Value
Type | Description |
---|---|
List<IValueValidator> |
ValueType
The value type which reflects how it is validated and stored in the database
Declaration
[DataMember(Name = "valueType")]
public string ValueType { get; set; }
Property Value
Type | Description |
---|---|
System.String |
View
Gets or sets the editor view.
Declaration
[Required]
[DataMember(Name = "view")]
public string View { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Remarks
The view can be three things: (1) the full virtual path, or (2) the relative path to the current Umbraco folder, or (3) a view name which maps to views/propertyeditors/{view}/{view}.html.
Methods
View SourceConvertDbToString(IPropertyType, Object)
Converts a property value to a string.
Declaration
public virtual string ConvertDbToString(IPropertyType propertyType, object value)
Parameters
Type | Name | Description |
---|---|---|
IPropertyType | propertyType | |
System.Object | value |
Returns
Type | Description |
---|---|
System.String |
ConvertDbToXml(IProperty, Boolean)
Converts a property to Xml fragments.
Declaration
public IEnumerable<XElement> ConvertDbToXml(IProperty property, bool published)
Parameters
Type | Name | Description |
---|---|---|
IProperty | property | |
System.Boolean | published |
Returns
Type | Description |
---|---|
IEnumerable<System.Xml.Linq.XElement> |
ConvertDbToXml(IPropertyType, Object)
Converts a property value to an Xml fragment.
Declaration
public XNode ConvertDbToXml(IPropertyType propertyType, object value)
Parameters
Type | Name | Description |
---|---|---|
IPropertyType | propertyType | |
System.Object | value |
Returns
Type | Description |
---|---|
System.Xml.Linq.XNode |
Remarks
By default, this returns the value of ConvertDbToString but ensures that if the db value type is NVarchar or NText, the value is returned as a CDATA fragment - else it's a Text fragment.
Returns an XText or XCData instance which must be wrapped in a element.
If the value is empty we will not return as CDATA since that will just take up more space in the file.
FromEditor(ContentPropertyData, Object)
A method to deserialize the string value that has been saved in the content editor to an object to be stored in the database.
Declaration
public virtual object FromEditor(ContentPropertyData editorValue, object currentValue)
Parameters
Type | Name | Description |
---|---|---|
ContentPropertyData | editorValue | The value returned by the editor. |
System.Object | currentValue | The current value that has been persisted to the database for this editor. This value may be useful for how the value then get's deserialized again to be re-persisted. In most cases it will probably not be used. |
Returns
Type | Description |
---|---|
System.Object | The value that gets persisted to the database. |
Remarks
By default this will attempt to automatically convert the string value to the value type supplied by ValueType. If overridden then the object returned must match the type supplied in the ValueType, otherwise persisting the value to the DB will fail when it tries to validate the value type.
ToEditor(IProperty, String, String)
A method used to format the database value to a value that can be used by the editor.
Declaration
public virtual object ToEditor(IProperty property, string culture = null, string segment = null)
Parameters
Type | Name | Description |
---|---|---|
IProperty | property | The property. |
System.String | culture | The culture. |
System.String | segment | The segment. |
Returns
Type | Description |
---|---|
System.Object |
Remarks
The object returned will automatically be serialized into JSON notation. For most property editors the value returned is probably just a string, but in some cases a JSON structure will be returned.
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | ValueType was out of range. |
Validate(Object, Boolean, String)
Validates a property value.
Declaration
public IEnumerable<ValidationResult> Validate(object value, bool required, string format)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The property value. |
System.Boolean | required | A value indicating whether the property value is required. |
System.String | format | A specific format (regex) that the property value must respect. |
Returns
Type | Description |
---|---|
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> |