Class ContentDataExtensions
Contains convenient extension methods to access properties for IContent
Inheritance
Namespace: EPiServer.Core
Assembly: EPiServer.dll
Version: 12.0.3Syntax
public static class ContentDataExtensions : Object
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 |
---|---|---|
IContent |
contentData | The object this method extends. |
System. |
propertyName | The property name |
Returns
Type | Description |
---|---|
TProperty |
The setting or |
Type Parameters
Name | Description |
---|---|
TPropertySettings | The type of property settings. |
Remarks
This methods uses Property
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 |
---|---|---|
TContent |
contentData | The object this method extends. |
System. |
expression | A lambda expression indication which property to get settings for. |
Returns
Type | Description |
---|---|
TProperty |
The setting or |
Type Parameters
Name | Description |
---|---|
TPropertySettings | The type of property settings. |
TContentData | The type of content. |
Remarks
This methods uses Property
GetPropertyValue(ContentData, String)
Returns the string representation of the value of a property of the
Content
Declaration
public static string GetPropertyValue(this ContentData contentData, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
Content |
contentData | Instance to read property from. |
System. |
propertyName | Name of the property. |
Returns
Type | Description |
---|---|
System. |
The string representation of the property value, or null if
the Property |
GetPropertyValue(ContentData, String, String)
Returns the string representation of the value of a property of the
Content
Declaration
public static string GetPropertyValue(this ContentData contentData, string propertyName, string defaultValue)
Parameters
Type | Name | Description |
---|---|---|
Content |
contentData | Instance to read property from. |
System. |
propertyName | Name of the property. |
System. |
defaultValue | A default value to return if the Property |
Returns
Type | Description |
---|---|
System. |
The string representation of the property value, or the specified
default value if the Property |
GetPropertyValue<TPropertyValue>(ContentData, String)
Returns the value of a property of the Content
Declaration
public static TPropertyValue GetPropertyValue<TPropertyValue>(this ContentData contentData, string propertyName)
Parameters
Type | Name | Description |
---|---|---|
Content |
contentData | Instance to read property from. |
System. |
propertyName | Name of the property. |
Returns
Type | Description |
---|---|
TProperty |
The property value, or the specified default value if the Property |
Type Parameters
Name | Description |
---|---|
TPropertyValue | The type the Property |
GetPropertyValue<TPropertyValue>(ContentData, String, TPropertyValue)
Returns the value of a property of the Content
Declaration
public static TPropertyValue GetPropertyValue<TPropertyValue>(this ContentData contentData, string propertyName, TPropertyValue defaultValue)
Parameters
Type | Name | Description |
---|---|---|
Content |
contentData | Instance to read property from. |
System. |
propertyName | Name of the property. |
TProperty |
defaultValue | A default value to return if the Property |
Returns
Type | Description |
---|---|
TProperty |
The property value, or the default value for the return type if the
Property |
Type Parameters
Name | Description |
---|---|
TPropertyValue | The type the Property |
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 |
---|---|---|
TContent |
contentData | The object this method extends. |
System. |
expression | A lambda expression indication which property to get. |
Returns
Type | Description |
---|---|
TProperty |
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 |
---|---|---|
TContent |
contentData | The object this method extends. |
System. |
expression | A lambda expression indication which property to get. |
TProperty |
defaultValue | The default value to use if no value is set on the specified property. |
Returns
Type | Description |
---|---|
TProperty |
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 |
---|---|---|
TContent |
contentData | The object this method extends. |
System. |
expression | A lambda expression indication which property to get. |
System. |
defaultValue | The default value to use if no value is set on the specified property. |
Returns
Type | Description |
---|---|
TProperty |
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 Content
Declaration
public static TResult GetPropertyValue<TPropertyValue, TResult>(this ContentData contentData, string propertyName, Func<TPropertyValue, TResult> resultSelector)
Parameters
Type | Name | Description |
---|---|---|
Content |
contentData | Instance to read property from. |
System. |
propertyName | Name of the property. |
System. |
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
Property |
Type Parameters
Name | Description |
---|---|
TPropertyValue | The type the Property |
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 Content
Declaration
public static TResult GetPropertyValue<TPropertyValue, TResult>(this ContentData contentData, string propertyName, Func<TPropertyValue, TResult> resultSelector, TResult defaultValue)
Parameters
Type | Name | Description |
---|---|---|
Content |
contentData | Instance to read property from. |
System. |
propertyName | Name of the property. |
System. |
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 Property |
Returns
Type | Description |
---|---|
TResult | The projected property value, or the specified default value if the
Property |
Type Parameters
Name | Description |
---|---|
TPropertyValue | The type the Property |
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 |
---|---|---|
TContent |
contentData | The object this method extends. |
System. |
expression | A lambda expression indication which property to get. |
System. |
valueRetriever | The function that retrieves the value from the property data object. |
System. |
defaultValue | The default value to use if no value is set on the specified property. |
Returns
Type | Description |
---|---|
TProperty |
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 |
---|---|---|
TContent |
contentData | The object this method extends. |
System. |
expression | A lambda expression indication which property to set. |
TProperty |
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 |
---|---|---|
TContent |
contentData | The object this method extends. |
System. |
expression | A lambda expression indication which property to set. |
System. |
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. |