Class PublishedElement
Represents a published element that provides access to content type information and properties.
Inheritance
Namespace: Umbraco.Cms.Core.PublishedCache
Assembly: Umbraco.Core.dll
Syntax
public class PublishedElement : IPublishedElement
Remarks
A published element does NOT manage any tree-like elements. It represents detached content that is not part of the content tree hierarchy (e.g., nested content items, block list items).
Constructors
View SourcePublishedElement(IPublishedContentType, Guid, Dictionary<string, object?>, bool, VariationContext)
Initializes a new instance of the PublishedElement class without any context, making it purely standalone and not interfering with the published snapshot service.
Declaration
public PublishedElement(IPublishedContentType contentType, Guid key, Dictionary<string, object?> values, bool previewing, VariationContext variationContext)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedContentType | contentType | The published content type. |
| Guid | key | The unique identifier for this element. |
| Dictionary<string, object> | values | The property values dictionary. |
| bool | previewing | A value indicating whether this is a preview request. |
| VariationContext | variationContext | The variation context for culture and segment. |
Remarks
Using an initial reference cache level of None ensures that everything will be cached at element level, and that reference cache level will propagate to all properties.
PublishedElement(IPublishedContentType, Guid, Dictionary<string, object?>?, bool, PropertyCacheLevel, VariationContext, ICacheManager?)
Initializes a new instance of the PublishedElement class within the context of a published snapshot service (e.g., a published content property value).
Declaration
public PublishedElement(IPublishedContentType contentType, Guid key, Dictionary<string, object?>? values, bool previewing, PropertyCacheLevel referenceCacheLevel, VariationContext variationContext, ICacheManager? cacheManager)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedContentType | contentType | The published content type. |
| Guid | key | The unique identifier for this element. |
| Dictionary<string, object> | values | The property values dictionary. |
| bool | previewing | A value indicating whether this is a preview request. |
| PropertyCacheLevel | referenceCacheLevel | The reference cache level for property value caching. |
| VariationContext | variationContext | The variation context for culture and segment. |
| ICacheManager | cacheManager | The cache manager for property value caching. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when |
| ArgumentNullException | Thrown when |
Properties
View SourceContentType
Gets the content type.
Declaration
public IPublishedContentType ContentType { get; }
Property Value
| Type | Description |
|---|---|
| IPublishedContentType |
Key
Gets the unique key of the published element.
Declaration
public Guid Key { get; }
Property Value
| Type | Description |
|---|---|
| Guid |
Properties
Gets the properties of the element.
Declaration
public IEnumerable<IPublishedProperty> Properties { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<IPublishedProperty> |
Remarks
Contains one IPublishedProperty for each property defined for the content type, including
inherited properties. Some properties may have no value.
Methods
View SourceGetProperty(string)
Gets a property identified by its alias.
Declaration
public IPublishedProperty? GetProperty(string alias)
Parameters
| Type | Name | Description |
|---|---|---|
| string | alias | The property alias. |
Returns
| Type | Description |
|---|---|
| IPublishedProperty | The property identified by the alias. |
Remarks
If the content type has no property with that alias, including inherited properties, returns null,
otherwise return a property -- that may have no value (ie HasValue is false).
The alias is case-insensitive.