November Happy Hour will be moved to Thursday December 5th.

Class IContentExtensions

Extends IContent with some convenient methods.

Inheritance
System.Object
IContentExtensions
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Core
Assembly: EPiServer.dll
Version: 9.12.2
Syntax
public static class IContentExtensions

Methods

GetForceCurrentVersionSaveAction(IContent)

Get SaveAction required to patch content without changing either status or creating a new version. Also bypasses validation.

Declaration
public static SaveAction GetForceCurrentVersionSaveAction(this IContent content)
Parameters
Type Name Description
IContent content

The content

Returns
Type Description
SaveAction

The SaveAction

GetPropertyName<TContent>(TContent, Expression<Func<TContent, Object>>)

Gets the property name from the expression.

Declaration
public static string GetPropertyName<TContent>(this TContent content, Expression<Func<TContent, object>> expression)
    where TContent : IContentData
Parameters
Type Name Description
TContent content

The content containing the property definition.

System.Linq.Expressions.Expression<System.Func<TContent, System.Object>> expression

The expression to get the property name. The expression needs to be a member expression or a unary expression.

Returns
Type Description
System.String

Name of the property

Type Parameters
Name Description
TContent

The content type.

GetTargetFrame(IContent)

Get the target frame for PageData to be used in links to pages

Declaration
public static string GetTargetFrame(this IContent content)
Parameters
Type Name Description
IContent content
Returns
Type Description
System.String

QueryAccess(IContent)

Return the access level that the current user has to the content

Declaration
public static AccessLevel QueryAccess(this IContent content)
Parameters
Type Name Description
IContent content

The content.

Returns
Type Description
AccessLevel

An AccessLevel

Remarks

Note that this method also checks the published status of the page to determine the actual access that the user has. I e if the page is not published the user will not see it unless he has "more" access than Read.

QueryDistinctAccess(IContent, AccessLevel)

Check for a distinct required access level. This is preferred to use over QueryAccess for performance reasons.

Declaration
public static bool QueryDistinctAccess(this IContent content, AccessLevel requestedLevel)
Parameters
Type Name Description
IContent content

The content.

AccessLevel requestedLevel

The requested level.

Returns
Type Description
System.Boolean

true if at least the requested access is held by the current user

Remarks

This method is optimized for speed, by checking preconditions before calling expensive methods.