Search Results for

    Show / Hide Table of Contents
    View Source

    Class DataValueEditor

    Represents a value editor.

    Inheritance
    System.Object
    Namespace: Umbraco.Cms.Core.PropertyEditors
    Assembly: Umbraco.Core.dll
    Syntax
    [DataContract]
    public class DataValueEditor : IDataValueEditor

    Constructors

    View Source

    DataValueEditor(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
    View Source

    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 Source

    Configuration

    Gets or sets the value editor configuration.

    Declaration
    public virtual object Configuration { get; set; }
    Property Value
    Type Description
    System.Object
    View Source

    FormatValidator

    Gets the validator used to validate the special property type -level "format".

    Declaration
    public virtual IValueFormatValidator FormatValidator { get; }
    Property Value
    Type Description
    IValueFormatValidator
    View Source

    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
    View Source

    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
    View Source

    RequiredValidator

    Gets the validator used to validate the special property type -level "required".

    Declaration
    public virtual IValueRequiredValidator RequiredValidator { get; }
    Property Value
    Type Description
    IValueRequiredValidator
    View Source

    SupportsReadOnly

    Declaration
    public bool SupportsReadOnly { get; set; }
    Property Value
    Type Description
    System.Boolean
    View Source

    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>
    View Source

    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 Source

    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 Source

    ConvertDbToString(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
    View Source

    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>
    View Source

    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.

    View Source

    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.

    View Source

    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.

    View Source

    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>
    • Improve this Doc
    • View Source
    In This Article
    • Constructors
      • DataValueEditor(ILocalizedTextService, IShortStringHelper, IJsonSerializer)
      • DataValueEditor(ILocalizedTextService, IShortStringHelper, IJsonSerializer, IIOHelper, DataEditorAttribute)
    • Properties
      • Configuration
      • FormatValidator
      • HideLabel
      • IsReadOnly
      • RequiredValidator
      • SupportsReadOnly
      • Validators
      • ValueType
      • View
    • Methods
      • ConvertDbToString(IPropertyType, Object)
      • ConvertDbToXml(IProperty, Boolean)
      • ConvertDbToXml(IPropertyType, Object)
      • FromEditor(ContentPropertyData, Object)
      • ToEditor(IProperty, String, String)
      • Validate(Object, Boolean, String)
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX