Class PublishedValueFallback
Provides a default implementation for IPublishedValueFallback.
Inheritance
Namespace: Umbraco.Cms.Core.Models.PublishedContent
Assembly: Umbraco.Core.dll
Syntax
public class PublishedValueFallback : IPublishedValueFallback
Constructors
View SourcePublishedValueFallback(ServiceContext, IVariationContextAccessor)
Initializes a new instance of the PublishedValueFallback class.
Declaration
public PublishedValueFallback(ServiceContext serviceContext, IVariationContextAccessor variationContextAccessor)
Parameters
| Type | Name | Description |
|---|---|---|
| ServiceContext | serviceContext | |
| IVariationContextAccessor | variationContextAccessor |
Methods
View SourceTryGetValue(IPublishedContent, String, String, String, Fallback, Object, out Object, out IPublishedProperty)
Tries to get a fallback value for a published content property.
Declaration
public bool TryGetValue(IPublishedContent content, string alias, string culture, string segment, Fallback fallback, object defaultValue, out object value, out IPublishedProperty noValueProperty)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedContent | content | The published element. |
| System.String | alias | The property alias. |
| System.String | culture | The requested culture. |
| System.String | segment | The requested segment. |
| Fallback | fallback | A fallback strategy. |
| System.Object | defaultValue | An optional default value. |
| System.Object | value | The fallback value. |
| IPublishedProperty | noValueProperty | The property that does not have a value. |
Returns
| Type | Description |
|---|---|
| System.Boolean | A value indicating whether a fallback value could be provided. |
Remarks
This method is called whenever getting the property value for the specified alias, culture and segment, either returned no property at all, or a property with HasValue(culture, segment) being false.
In an IPublishedContent, because walking up the tree is possible, the content itself may not
even
have a property with the specified alias, but such a property may exist up in the tree. The
noValueProperty
parameter is used to return a property with no value. That can then be used to invoke a converter and get the
converter's interpretation of "no value".
TryGetValue(IPublishedElement, String, String, String, Fallback, Object, out Object)
Tries to get a fallback value for a published element property.
Declaration
public bool TryGetValue(IPublishedElement content, string alias, string culture, string segment, Fallback fallback, object defaultValue, out object value)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedElement | content | The published element. |
| System.String | alias | The property alias. |
| System.String | culture | The requested culture. |
| System.String | segment | The requested segment. |
| Fallback | fallback | A fallback strategy. |
| System.Object | defaultValue | An optional default value. |
| System.Object | value | The fallback value. |
Returns
| Type | Description |
|---|---|
| System.Boolean | A value indicating whether a fallback value could be provided. |
Remarks
This method is called whenever getting the property value for the specified alias, culture and segment, either returned no property at all, or a property with HasValue(culture, segment) being false.
It can only fallback at element level (no recurse).
TryGetValue(IPublishedProperty, String, String, Fallback, Object, out Object)
Tries to get a fallback value for a property.
Declaration
public bool TryGetValue(IPublishedProperty property, string culture, string segment, Fallback fallback, object defaultValue, out object value)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedProperty | property | The property. |
| System.String | culture | The requested culture. |
| System.String | segment | The requested segment. |
| Fallback | fallback | A fallback strategy. |
| System.Object | defaultValue | An optional default value. |
| System.Object | value | The fallback value. |
Returns
| Type | Description |
|---|---|
| System.Boolean | A value indicating whether a fallback value could be provided. |
Remarks
This method is called whenever property.Value(culture, segment, defaultValue) is called, and property.HasValue(culture, segment) is false.
It can only fallback at property level (no recurse).
At property level, property.GetValue() does not implement fallback, and one has to get property.Value() or property.Value{T}() to trigger fallback.
Note that culture and segment may not be contextualized,
so the variant context should be used to contextualize them (see our default implementation in
the web project.
TryGetValue<T>(IPublishedContent, String, String, String, Fallback, T, out T, out IPublishedProperty)
Tries to get a fallback value for a published content property.
Declaration
public virtual bool TryGetValue<T>(IPublishedContent content, string alias, string culture, string segment, Fallback fallback, T defaultValue, out T value, out IPublishedProperty noValueProperty)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedContent | content | The published element. |
| System.String | alias | The property alias. |
| System.String | culture | The requested culture. |
| System.String | segment | The requested segment. |
| Fallback | fallback | A fallback strategy. |
| T | defaultValue | An optional default value. |
| T | value | The fallback value. |
| IPublishedProperty | noValueProperty | The property that does not have a value. |
Returns
| Type | Description |
|---|---|
| System.Boolean | A value indicating whether a fallback value could be provided. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the value. |
Remarks
This method is called whenever getting the property value for the specified alias, culture and segment, either returned no property at all, or a property with HasValue(culture, segment) being false.
In an IPublishedContent, because walking up the tree is possible, the content itself may not
even
have a property with the specified alias, but such a property may exist up in the tree. The
noValueProperty
parameter is used to return a property with no value. That can then be used to invoke a converter and get the
converter's interpretation of "no value".
TryGetValue<T>(IPublishedElement, String, String, String, Fallback, T, out T)
Tries to get a fallback value for a published element property.
Declaration
public bool TryGetValue<T>(IPublishedElement content, string alias, string culture, string segment, Fallback fallback, T defaultValue, out T value)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedElement | content | The published element. |
| System.String | alias | The property alias. |
| System.String | culture | The requested culture. |
| System.String | segment | The requested segment. |
| Fallback | fallback | A fallback strategy. |
| T | defaultValue | An optional default value. |
| T | value | The fallback value. |
Returns
| Type | Description |
|---|---|
| System.Boolean | A value indicating whether a fallback value could be provided. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the value. |
Remarks
This method is called whenever getting the property value for the specified alias, culture and segment, either returned no property at all, or a property with HasValue(culture, segment) being false.
It can only fallback at element level (no recurse).
TryGetValue<T>(IPublishedProperty, String, String, Fallback, T, out T)
Tries to get a fallback value for a property.
Declaration
public bool TryGetValue<T>(IPublishedProperty property, string culture, string segment, Fallback fallback, T defaultValue, out T value)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedProperty | property | The property. |
| System.String | culture | The requested culture. |
| System.String | segment | The requested segment. |
| Fallback | fallback | A fallback strategy. |
| T | defaultValue | An optional default value. |
| T | value | The fallback value. |
Returns
| Type | Description |
|---|---|
| System.Boolean | A value indicating whether a fallback value could be provided. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the value. |
Remarks
This method is called whenever property.Value{T}(culture, segment, defaultValue) is called, and property.HasValue(culture, segment) is false.
It can only fallback at property level (no recurse).
At property level, property.GetValue() does not implement fallback, and one has to get property.Value() or property.Value{T}() to trigger fallback.