Search Results for

    Show / Hide Table of Contents
    View Source

    Class DateTimeValueConverterBase

    Provides base functionality for date time property value converters that store their value as a JSON string with timezone information.

    Inheritance
    object
    PropertyValueConverterBase
    Namespace: Umbraco.Cms.Core.PropertyEditors.ValueConverters
    Assembly: Umbraco.Infrastructure.dll
    Syntax
    [DefaultPropertyValueConverter(new Type[] { typeof(JsonValueConverter) })]
    public abstract class DateTimeValueConverterBase : PropertyValueConverterBase, IPropertyValueConverter, IDiscoverable

    Constructors

    View Source

    DateTimeValueConverterBase(IJsonSerializer, ILogger)

    Initializes a new instance of the DateTimeValueConverterBase class.

    Declaration
    protected DateTimeValueConverterBase(IJsonSerializer jsonSerializer, ILogger logger)
    Parameters
    Type Name Description
    IJsonSerializer jsonSerializer

    The JSON serializer.

    ILogger logger

    The logger.

    Methods

    View Source

    ConvertIntermediateToObject(IPublishedElement, IPublishedPropertyType, PropertyCacheLevel, object?, bool)

    Converts a property intermediate value to an Object value.

    Declaration
    public override object? ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object? inter, bool preview)
    Parameters
    Type Name Description
    IPublishedElement owner

    The property set owning the property.

    IPublishedPropertyType propertyType

    The property type.

    PropertyCacheLevel referenceCacheLevel

    The reference cache level.

    object inter

    The intermediate value.

    bool preview

    A value indicating whether conversion should take place in preview mode.

    Returns
    Type Description
    object

    The result of the conversion.

    Remarks

    The converter should know how to convert a null intermediate value, or any intermediate value indicating that no value has been assigned to the property. It is up to the converter to determine what to return in that case: either null, or the default value...

    The referenceCacheLevel is passed to the converter so that it can be, in turn, passed to eg a PublishedFragment constructor. It is used by the fragment and the properties to manage the cache levels of property values. It is not meant to be used by the converter.

    View Source

    ConvertSourceToIntermediate(IPublishedElement, IPublishedPropertyType, object?, bool)

    Converts a property source value to an intermediate value.

    Declaration
    public override object? ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object? source, bool preview)
    Parameters
    Type Name Description
    IPublishedElement owner

    The property set owning the property.

    IPublishedPropertyType propertyType

    The property type.

    object source

    The source value.

    bool preview

    A value indicating whether conversion should take place in preview mode.

    Returns
    Type Description
    object

    The result of the conversion.

    Remarks

    The converter should know how to convert a null source value, meaning that no value has been assigned to the property. The intermediate value can be null.

    With the XML cache, source values come from the XML cache and therefore are strings.

    With objects caches, source values would come from the database and therefore be either ints, DateTimes, decimals, or strings.

    The converter should be prepared to handle both situations.

    When source values are strings, the converter must handle empty strings, whitespace strings, and xml-whitespace strings appropriately, ie it should know whether to preserve white spaces.

    View Source

    ConvertToObject(DateTimeDto)

    Convert the intermediate representation to the final object.

    Declaration
    protected abstract object ConvertToObject(DateTimeValueConverterBase.DateTimeDto dateTimeDto)
    Parameters
    Type Name Description
    DateTimeValueConverterBase.DateTimeDto dateTimeDto

    The intermediate representation.

    Returns
    Type Description
    object

    The final object.

    View Source

    GetPropertyCacheLevel(IPublishedPropertyType)

    Gets the property cache level.

    Declaration
    public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
    Parameters
    Type Name Description
    IPublishedPropertyType propertyType

    The property type.

    Returns
    Type Description
    PropertyCacheLevel

    The property cache level.

    View Source

    IsConverter(IPublishedPropertyType)

    Gets a value indicating whether the converter supports a property type.

    Declaration
    public override abstract bool IsConverter(IPublishedPropertyType propertyType)
    Parameters
    Type Name Description
    IPublishedPropertyType propertyType

    The property type.

    Returns
    Type Description
    bool

    A value indicating whether the converter supports a property type.

    • Edit this page
    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX