Class MultiUrlPickerValueConverter
Converts the value stored by the Multi URL Picker property editor into a collection of strongly-typed link objects that can be easily consumed by application code.
Namespace: Umbraco.Cms.Core.PropertyEditors.ValueConverters
Assembly: Umbraco.Infrastructure.dll
Syntax
[DefaultPropertyValueConverter(new Type[] { typeof(JsonValueConverter) })]
public class MultiUrlPickerValueConverter : PropertyValueConverterBase, IDeliveryApiPropertyValueConverter, IPropertyValueConverter, IDiscoverable
Constructors
View SourceMultiUrlPickerValueConverter(IProfilingLogger, IJsonSerializer, IPublishedUrlProvider, IApiContentNameProvider, IApiMediaUrlProvider, IApiContentRouteBuilder, IPublishedContentCache, IPublishedMediaCache)
Initializes a new instance of the MultiUrlPickerValueConverter class with the specified dependencies.
Declaration
public MultiUrlPickerValueConverter(IProfilingLogger proflog, IJsonSerializer jsonSerializer, IPublishedUrlProvider publishedUrlProvider, IApiContentNameProvider apiContentNameProvider, IApiMediaUrlProvider apiMediaUrlProvider, IApiContentRouteBuilder apiContentRouteBuilder, IPublishedContentCache contentCache, IPublishedMediaCache mediaCache)
Parameters
| Type | Name | Description |
|---|---|---|
| IProfilingLogger | proflog | The IProfilingLogger used for profiling and logging. |
| IJsonSerializer | jsonSerializer | The IJsonSerializer used for serializing and deserializing JSON data. |
| IPublishedUrlProvider | publishedUrlProvider | The IPublishedUrlProvider used to provide published URLs. |
| IApiContentNameProvider | apiContentNameProvider | The IApiContentNameProvider used to provide API content names. |
| IApiMediaUrlProvider | apiMediaUrlProvider | The IApiMediaUrlProvider used to provide API media URLs. |
| IApiContentRouteBuilder | apiContentRouteBuilder | The IApiContentRouteBuilder used to build API content routes. |
| IPublishedContentCache | contentCache | The IPublishedContentCache used to cache published content. |
| IPublishedMediaCache | mediaCache | The IPublishedMediaCache used to cache published media. |
Methods
View SourceConvertIntermediateToDeliveryApiObject(IPublishedElement, IPublishedPropertyType, PropertyCacheLevel, object?, bool, bool)
Converts the intermediate value of a multi URL picker property to an object 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 published element that owns the property. |
| IPublishedPropertyType | propertyType | The type of the published property. |
| PropertyCacheLevel | referenceCacheLevel | The cache level for property references. |
| object | inter | The intermediate value to convert, typically a JSON string representing the links. |
| bool | preview | A value indicating whether the conversion is for preview mode. |
| bool | expanding | A value indicating whether nested properties are being expanded during conversion. |
Returns
| Type | Description |
|---|---|
| object | An array of ApiLink objects representing the converted links for the Delivery API, or an empty array if the intermediate value is null, empty, or cannot be parsed. |
ConvertIntermediateToObject(IPublishedElement, IPublishedPropertyType, PropertyCacheLevel, object?, bool)
Converts the intermediate value to the final object representation for the MultiUrlPicker property editor.
Declaration
public override object? ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object? inter, bool preview)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedElement | owner | The published element that owns the property. |
| IPublishedPropertyType | propertyType | The published property type. |
| PropertyCacheLevel | referenceCacheLevel | The cache level for reference resolution. |
| object | inter | The intermediate value to convert. |
| bool | preview | Indicates whether the conversion is for preview mode. |
Returns
| Type | Description |
|---|---|
| object | If the maximum number of links is 1, returns a single Link or |
ConvertSourceToIntermediate(IPublishedElement, IPublishedPropertyType, object?, bool)
Converts the source value to its string representation as an intermediate value.
Declaration
public override object? ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object? source, bool preview)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedElement | owner | The published element that owns the property. |
| IPublishedPropertyType | propertyType | The type of the published property. |
| object | source | The source value to convert. |
| bool | preview | Indicates whether the conversion is for preview mode. |
Returns
| Type | Description |
|---|---|
| object | The string representation of the source value, or |
GetDeliveryApiPropertyCacheLevel(IPublishedPropertyType)
Returns the cache level to be used by the delivery API for the specified published property type.
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 value indicating the cache level for the delivery API. |
GetDeliveryApiPropertyValueType(IPublishedPropertyType)
Gets the type used by the Delivery API to represent the value of a Multi URL Picker property.
Declaration
public Type GetDeliveryApiPropertyValueType(IPublishedPropertyType propertyType)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedPropertyType | propertyType | The published property type (not used in this implementation). |
Returns
| Type | Description |
|---|---|
| Type | The System.Collections.Generic.IEnumerable<T> type. |
GetPropertyCacheLevel(IPublishedPropertyType)
Gets the cache level at which the property value is stored for the Multi URL Picker value converter.
Declaration
public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedPropertyType | propertyType | The published property type for which to determine the cache level. |
Returns
| Type | Description |
|---|---|
| PropertyCacheLevel | The Snapshot cache level, indicating the value is cached for the duration of a published snapshot. |
GetPropertyValueType(IPublishedPropertyType)
Determines and returns the .NET type that will be used to represent the value of the property, based on whether the property type is configured as a single or multiple URL picker.
Declaration
public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedPropertyType | propertyType | The published property type to evaluate. |
Returns
| Type | Description |
|---|---|
| Type | Link if the property is a single URL picker; otherwise, System.Collections.Generic.IEnumerable<T> for multiple URLs. |
IsConverter(IPublishedPropertyType)
Determines whether this value converter should be used for the specified property type.
Declaration
public override bool IsConverter(IPublishedPropertyType propertyType)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedPropertyType | propertyType | The property type to evaluate. |
Returns
| Type | Description |
|---|---|
| bool |
|
IsValue(object?, PropertyValueLevel)
Determines whether the specified value should be considered a valid value for the multi URL picker property editor.
Declaration
public override bool? IsValue(object? value, PropertyValueLevel level)
Parameters
| Type | Name | Description |
|---|---|---|
| object | value | The value to evaluate. |
| PropertyValueLevel | level | The level of the property value. |
Returns
| Type | Description |
|---|---|
| bool? |
|