Class ContentDataExtensions
Inheritance
Inherited Members
Namespace: EPiServer.Core
Assembly: EPiServer.dll
Version: 9.12.2Syntax
public static class ContentDataExtensions
Methods
GetPropertySettings<TPropertySettings>(IContentData, String)
Get the property settings from a specified property.
Declaration
public static TPropertySettings GetPropertySettings<TPropertySettings>(this IContentData contentData, string propertyName)
where TPropertySettings : IPropertySettings
Parameters
Type | Name | Description |
---|---|---|
IContentData | contentData | The object this method extends. |
System.String | propertyName | The property name |
Returns
Type | Description |
---|---|
TPropertySettings | The setting or |
Type Parameters
Name | Description |
---|---|
TPropertySettings | The type of property settings. |
Remarks
This methods uses PropertySettingsResolver to resolve the settings.
GetPropertySettings<TPropertySettings, TContentData>(TContentData, Expression<Func<TContentData, Object>>)
Get the property settings from a specified property.
Declaration
public static TPropertySettings GetPropertySettings<TPropertySettings, TContentData>(this TContentData contentData, Expression<Func<TContentData, object>> expression)
where TPropertySettings : IPropertySettings where TContentData : IContentData
Parameters
Type | Name | Description |
---|---|---|
TContentData | contentData | The object this method extends. |
System.Linq.Expressions.Expression<System.Func<TContentData, System.Object>> | expression | A lambda expression indication which property to get settings for. |
Returns
Type | Description |
---|---|
TPropertySettings | The setting or |
Type Parameters
Name | Description |
---|---|
TPropertySettings | The type of property settings. |
TContentData | The type of content. |
Remarks
This methods uses PropertySettingsResolver to resolve the settings.
GetPropertyValue(ContentData, String)
Returns the string representation of the value of a property of the ContentData instance, taking into account that PropertyData or the Value property of the PropertyData may be null, in which case null is returned. The value is converted to a string using the type's ToString method.
Declaration
public static string GetPropertyValue(this ContentData contentData, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
ContentData | contentData | Instance to read property from. |
System.String | propertyName | Name of the property. |
Returns
Type | Description |
---|---|
System.String | The string representation of the property value, or null if the PropertyData or the Value property of the PropertyData is null. |
GetPropertyValue(ContentData, String, String)
Returns the string representation of the value of a property of the ContentData instance, taking into account that PropertyData or the Value property of the PropertyData may be null, in which case the specified default value is returned. The value is converted to a string using the type's ToString method.
Declaration
public static string GetPropertyValue(this ContentData contentData, string propertyName, string defaultValue)
Parameters
Type | Name | Description |
---|---|---|
ContentData | contentData | Instance to read property from. |
System.String | propertyName | Name of the property. |
System.String | defaultValue | A default value to return if the PropertyData or the Value property of the PropertyData is null |
Returns
Type | Description |
---|---|
System.String | The string representation of the property value, or the specified default value if the PropertyData or the Value property of the PropertyData is null. |
GetPropertyValue<TPropertyValue>(ContentData, String)
Returns the value of a property of the ContentData instance, taking into account that PropertyData or the Value property of the PropertyData may be null, in which case the specified default value is returned. The value is cast to the specified type.
Declaration
public static TPropertyValue GetPropertyValue<TPropertyValue>(this ContentData contentData, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
ContentData | contentData | Instance to read property from. |
System.String | propertyName | Name of the property. |
Returns
Type | Description |
---|---|
TPropertyValue | The property value, or the specified default value if the PropertyData or the Value property of the PropertyData is null. |
Type Parameters
Name | Description |
---|---|
TPropertyValue | The type the PropertyData Value has. |
GetPropertyValue<TPropertyValue>(ContentData, String, TPropertyValue)
Returns the value of a property of the ContentData instance, taking into account that PropertyData or the Value property of the PropertyData may be null, in which case the default value for the return type is returned. The value is cast to the specified type.
Declaration
public static TPropertyValue GetPropertyValue<TPropertyValue>(this ContentData contentData, string propertyName, TPropertyValue defaultValue)
Parameters
Type | Name | Description |
---|---|---|
ContentData | contentData | Instance to read property from. |
System.String | propertyName | Name of the property. |
TPropertyValue | defaultValue | A default value to return if the PropertyData or the Value property of the PropertyData is null |
Returns
Type | Description |
---|---|
TPropertyValue | The property value, or the default value for the return type if the PropertyData or the Value property of the PropertyData is null. |
Type Parameters
Name | Description |
---|---|
TPropertyValue | The type the PropertyData Value has. |
GetPropertyValue<TContentData, TPropertyValue>(TContentData, Expression<Func<TContentData, TPropertyValue>>)
Returns the value for a property on a content data object.
Declaration
public static TPropertyValue GetPropertyValue<TContentData, TPropertyValue>(this TContentData contentData, Expression<Func<TContentData, TPropertyValue>> expression)
where TContentData : ContentData
Parameters
Type | Name | Description |
---|---|---|
TContentData | contentData | The object this method extends. |
System.Linq.Expressions.Expression<System.Func<TContentData, TPropertyValue>> | expression | A lambda expression indication which property to get. |
Returns
Type | Description |
---|---|
TPropertyValue | The value of the specified property |
Type Parameters
Name | Description |
---|---|
TContentData | The type of page data. |
TPropertyValue | The type of the property value. |
GetPropertyValue<TContentData, TPropertyValue>(TContentData, Expression<Func<TContentData, TPropertyValue>>, TPropertyValue)
Returns the value for a property on a content data object.
Declaration
public static TPropertyValue GetPropertyValue<TContentData, TPropertyValue>(this TContentData contentData, Expression<Func<TContentData, TPropertyValue>> expression, TPropertyValue defaultValue)
where TContentData : ContentData
Parameters
Type | Name | Description |
---|---|---|
TContentData | contentData | The object this method extends. |
System.Linq.Expressions.Expression<System.Func<TContentData, TPropertyValue>> | expression | A lambda expression indication which property to get. |
TPropertyValue | defaultValue | The default value to use if no value is set on the specified property. |
Returns
Type | Description |
---|---|
TPropertyValue | The value of the specified property |
Type Parameters
Name | Description |
---|---|
TContentData | The type of page data. |
TPropertyValue | The type of the property value. |
GetPropertyValue<TContentData, TPropertyValue>(TContentData, Expression<Func<TContentData, TPropertyValue>>, Func<TPropertyValue>)
Returns the value for a property on a content data object.
Declaration
public static TPropertyValue GetPropertyValue<TContentData, TPropertyValue>(this TContentData contentData, Expression<Func<TContentData, TPropertyValue>> expression, Func<TPropertyValue> defaultValue)
where TContentData : ContentData
Parameters
Type | Name | Description |
---|---|---|
TContentData | contentData | The object this method extends. |
System.Linq.Expressions.Expression<System.Func<TContentData, TPropertyValue>> | expression | A lambda expression indication which property to get. |
System.Func<TPropertyValue> | defaultValue | The default value to use if no value is set on the specified property. |
Returns
Type | Description |
---|---|
TPropertyValue | The value of the specified property |
Type Parameters
Name | Description |
---|---|
TContentData | The type of content data. |
TPropertyValue | The type of the property value. |
GetPropertyValue<TPropertyValue, TResult>(ContentData, String, Func<TPropertyValue, TResult>)
Returns the value of a property of the ContentData instance, taking into account that PropertyData or the Value property of the PropertyData may be null, in which case the default value for the return type is returned. The value is cast to the specified type and then projected to the return type using the supplied delegate.
Declaration
public static TResult GetPropertyValue<TPropertyValue, TResult>(this ContentData contentData, string propertyName, Func<TPropertyValue, TResult> resultSelector)
Parameters
Type | Name | Description |
---|---|---|
ContentData | contentData | Instance to read property from. |
System.String | propertyName | Name of the property. |
System.Func<TPropertyValue, TResult> | resultSelector | A delegate which will be called if a value is successfully retrieved from the property, to perform additional conversions. |
Returns
Type | Description |
---|---|
TResult | The projected property value, or the default value for the return type if the PropertyData or the Value property of the PropertyData is null. |
Type Parameters
Name | Description |
---|---|
TPropertyValue | The type the PropertyData Value has. |
TResult | The type the property value will be projected to. |
GetPropertyValue<TPropertyValue, TResult>(ContentData, String, Func<TPropertyValue, TResult>, TResult)
Returns the value of a property of the ContentData instance, taking into account that PropertyData or the Value property of the PropertyData may be null, in which case the specified default value is returned. The value is cast to the specified type and then projected to the return type using the supplied delegate.
Declaration
public static TResult GetPropertyValue<TPropertyValue, TResult>(this ContentData contentData, string propertyName, Func<TPropertyValue, TResult> resultSelector, TResult defaultValue)
Parameters
Type | Name | Description |
---|---|---|
ContentData | contentData | Instance to read property from. |
System.String | propertyName | Name of the property. |
System.Func<TPropertyValue, TResult> | resultSelector | A delegate which will be called if a value is successfully retrieved from the property, to perform additional conversions. |
TResult | defaultValue | A default value to return if the PropertyData or the Value property of the PropertyData is null |
Returns
Type | Description |
---|---|
TResult | The projected property value, or the specified default value if the PropertyData or the Value property of the PropertyData is null. |
Type Parameters
Name | Description |
---|---|
TPropertyValue | The type the PropertyData Value has. |
TResult | The type the property value will be projected to. |
GetPropertyValue<TContentData, TPropertyData, TPropertyValue>(TContentData, Expression<Func<TContentData, TPropertyValue>>, Func<TPropertyData, TPropertyValue>, Func<TPropertyValue>)
Returns the value for a property on a content data object.
Declaration
public static TPropertyValue GetPropertyValue<TContentData, TPropertyData, TPropertyValue>(this TContentData contentData, Expression<Func<TContentData, TPropertyValue>> expression, Func<TPropertyData, TPropertyValue> valueRetriever, Func<TPropertyValue> defaultValue)
where TContentData : ContentData where TPropertyData : PropertyData
Parameters
Type | Name | Description |
---|---|---|
TContentData | contentData | The object this method extends. |
System.Linq.Expressions.Expression<System.Func<TContentData, TPropertyValue>> | expression | A lambda expression indication which property to get. |
System.Func<TPropertyData, TPropertyValue> | valueRetriever | The function that retrieves the value from the property data object. |
System.Func<TPropertyValue> | defaultValue | The default value to use if no value is set on the specified property. |
Returns
Type | Description |
---|---|
TPropertyValue | The value of the specified property |
Type Parameters
Name | Description |
---|---|
TContentData | The type of page data. |
TPropertyData | The type of the property data. |
TPropertyValue | The type of the property value. |
SetPropertyValue<TContentData, TPropertyValue>(TContentData, Expression<Func<TContentData, TPropertyValue>>, TPropertyValue)
Sets the specified value on a specified property.
Declaration
public static void SetPropertyValue<TContentData, TPropertyValue>(this TContentData contentData, Expression<Func<TContentData, TPropertyValue>> expression, TPropertyValue propertyValue)
where TContentData : ContentData
Parameters
Type | Name | Description |
---|---|---|
TContentData | contentData | The object this method extends. |
System.Linq.Expressions.Expression<System.Func<TContentData, TPropertyValue>> | expression | A lambda expression indication which property to set. |
TPropertyValue | propertyValue | The value to set on the specified property. |
Type Parameters
Name | Description |
---|---|
TContentData | The type of page data. |
TPropertyValue | The type of the property value. |
SetPropertyValue<TContentData, TPropertyData, TPropertyValue>(TContentData, Expression<Func<TContentData, TPropertyValue>>, Action<TPropertyData>)
Sets the specified value on a specified property.
Declaration
public static void SetPropertyValue<TContentData, TPropertyData, TPropertyValue>(this TContentData contentData, Expression<Func<TContentData, TPropertyValue>> expression, Action<TPropertyData> valueAction)
where TContentData : ContentData where TPropertyData : PropertyData
Parameters
Type | Name | Description |
---|---|---|
TContentData | contentData | The object this method extends. |
System.Linq.Expressions.Expression<System.Func<TContentData, TPropertyValue>> | expression | A lambda expression indication which property to set. |
System.Action<TPropertyData> | valueAction | The action function that sets the value of the property data object |
Type Parameters
Name | Description |
---|---|
TContentData | The type of page data. |
TPropertyData | |
TPropertyValue | The type of the property value. |