Search Results for

    Show / Hide Table of Contents
    View Source

    Class ImageCropperValueConverter

    Represents a value converter for the image cropper value editor.

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

    Constructors

    View Source

    ImageCropperValueConverter(ILogger<ImageCropperValueConverter>, IJsonSerializer)

    Initializes a new instance of the ImageCropperValueConverter class.

    Declaration
    public ImageCropperValueConverter(ILogger<ImageCropperValueConverter> logger, IJsonSerializer jsonSerializer)
    Parameters
    Type Name Description
    ILogger<ImageCropperValueConverter> logger

    An Microsoft.Extensions.Logging.ILogger<TCategoryName> used for logging.

    IJsonSerializer jsonSerializer

    An IJsonSerializer used to deserialize JSON data.

    Methods

    View Source

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

    Converts an ImageCropperValue intermediate value into an Umbraco.Cms.Core.Models.DeliveryApi.ApiImageCropperValue suitable for the Delivery API.

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

    The IPublishedElement that owns the property.

    IPublishedPropertyType propertyType

    The IPublishedPropertyType of the property being converted.

    PropertyCacheLevel referenceCacheLevel

    The cache level at which the reference is stored.

    object inter

    The intermediate value to convert, expected to be an ImageCropperValue.

    bool preview

    Indicates whether the conversion is for preview mode.

    bool expanding

    Indicates whether the value is being expanded for nested property conversion.

    Returns
    Type Description
    object

    An Umbraco.Cms.Core.Models.DeliveryApi.ApiImageCropperValue representing the image cropper data, or null if the intermediate value is not a valid ImageCropperValue.

    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

    GetDeliveryApiPropertyCacheLevel(IPublishedPropertyType)

    Determines the appropriate PropertyCacheLevel to use for the delivery API based on the specified IPublishedPropertyType.

    Declaration
    public PropertyCacheLevel GetDeliveryApiPropertyCacheLevel(IPublishedPropertyType propertyType)
    Parameters
    Type Name Description
    IPublishedPropertyType propertyType

    The published property type for which to determine the cache level.

    Returns
    Type Description
    PropertyCacheLevel

    The PropertyCacheLevel to be used for the delivery API.

    View Source

    GetDeliveryApiPropertyValueType(IPublishedPropertyType)

    Returns the .NET type used by the Delivery API to represent the value of an image cropper property for the specified property type.

    Declaration
    public Type GetDeliveryApiPropertyValueType(IPublishedPropertyType propertyType)
    Parameters
    Type Name Description
    IPublishedPropertyType propertyType

    The published property type for which to determine the Delivery API value type.

    Returns
    Type Description
    Type

    The System.Type representing the Delivery API value for the image cropper property.

    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

    GetPropertyValueType(IPublishedPropertyType)

    Gets the type of values returned by the converter.

    Declaration
    public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
    Parameters
    Type Name Description
    IPublishedPropertyType propertyType

    The property type.

    Returns
    Type Description
    Type

    The CLR type of values returned by the converter.

    Remarks

    Some of the CLR types may be generated, therefore this method cannot directly return a Type object (which may not exist yet). In which case it needs to return a ModelType instance.

    View Source

    IsConverter(IPublishedPropertyType)

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

    Declaration
    public override 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.

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