Class RawValueProperty
Provides a base class for IPublishedProperty implementations which converts and caches
the value source to the actual value to use when rendering content.
Namespace: Umbraco.Cms.Core.Models.PublishedContent
Assembly: Umbraco.Core.dll
Syntax
public class RawValueProperty : PublishedPropertyBase, IPublishedProperty
Remarks
Conversions results are stored within the property and will not be refreshed, so this class is not suitable for cached properties.
Does not support variations: the ctor throws if the property type supports variations.
Constructors
View SourceRawValueProperty(IPublishedPropertyType, IPublishedElement, object, bool)
Declaration
public RawValueProperty(IPublishedPropertyType propertyType, IPublishedElement content, object sourceValue, bool isPreviewing = false)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedPropertyType | propertyType | |
| IPublishedElement | content | |
| object | sourceValue | |
| bool | isPreviewing |
Methods
View SourceGetDeliveryApiValue(bool, string?, string?)
Gets the object value of the property for Delivery API representation.
Declaration
public override object? GetDeliveryApiValue(bool expanding, string? culture = null, string? segment = null)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | expanding | |
| string | culture | |
| string | segment |
Returns
| Type | Description |
|---|---|
| object |
Remarks
The value is what you want to use when rendering content through the Delivery API.
It can be null, or any type of CLR object.
It has been fully prepared and processed by the appropriate converter.
GetSourceValue(string?, string?)
Gets the source value of the property.
Declaration
public override object? GetSourceValue(string? culture = null, string? segment = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | culture | |
| string | segment |
Returns
| Type | Description |
|---|---|
| object |
Remarks
The source value is whatever was passed to the property when it was instantiated, and it is somewhat implementation-dependent -- depending on how the IPublishedCache is implemented.
The XmlPublishedCache source values are strings exclusively since they come from the Xml cache.
For other caches that get their source value from the database, it would be either a string, an integer (Int32), a date and time (DateTime) or a decimal (double).
If you're using that value, you're probably wrong, unless you're doing some internal Umbraco stuff.
GetValue(string?, string?)
Gets the object value of the property.
Declaration
public override object? GetValue(string? culture = null, string? segment = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | culture | |
| string | segment |
Returns
| Type | Description |
|---|---|
| object |
Remarks
The value is what you want to use when rendering content in an MVC view ie in C#.
It can be null, or any type of CLR object.
It has been fully prepared and processed by the appropriate converter.
HasValue(string?, string?)
Gets a value indicating whether the property has a value.
Declaration
public override bool HasValue(string? culture = null, string? segment = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | culture | |
| string | segment |
Returns
| Type | Description |
|---|---|
| bool |
Remarks
This is somewhat implementation-dependent -- depending on whatever IPublishedCache considers a missing value.
The XmlPublishedCache raw values are strings, and it will consider missing, null or empty (and that includes whitespace-only) strings as "no value".
Other caches that get their raw value from the database would consider that a property has "no value" if it is missing, null, or an empty string (including whitespace-only).