Try our conversational search powered by Generative AI!

Interface IContentLoader

Describes a service that can be used to read content data objects from a repository.

Namespace: EPiServer
Assembly: EPiServer.dll
Version: 11.20.7
Syntax
public interface IContentLoader

Methods

Get<T>(ContentReference)

Gets the content item represented by the provided reference.

Declaration
T Get<T>(ContentReference contentLink)
    where T : IContentData
Parameters
Type Name Description
ContentReference contentLink

The link to the content.

Returns
Type Description
T

The requested content item, as the specified type.

Type Parameters
Name Description
T

The type of content to get.

Exceptions
Type Condition
TypeMismatchException

Is thrown if actual type is not assignable to T.

ContentNotFoundException

Is thrown if there is no IContent instance with contentLink as id.

Get<T>(ContentReference, LoaderOptions)

Gets the content item represented by the provided reference given the settings specified by settings, for example Language.

Declaration
T Get<T>(ContentReference contentLink, LoaderOptions settings)
    where T : IContentData
Parameters
Type Name Description
ContentReference contentLink

The link to the content.

LoaderOptions settings

The settings that specifies how content should be loaded.

Returns
Type Description
T

The requested content, as the specified type, in the specified language.

Type Parameters
Name Description
T

The type of content to get.

Exceptions
Type Condition
TypeMismatchException

Is thrown if actual type is not assignable to T.

ContentNotFoundException

Is thrown if there is no IContent instance with contentLink as id.

Get<T>(ContentReference, CultureInfo)

Gets the specific language of content item represented by the provided reference.

Declaration
T Get<T>(ContentReference contentLink, CultureInfo language)
    where T : IContentData
Parameters
Type Name Description
ContentReference contentLink

The link to the content.

System.Globalization.CultureInfo language

The language

Returns
Type Description
T

The requested content item, as the specified type.

Type Parameters
Name Description
T

The type of content to get.

Remarks

If the contentLink is a specific version (that is where WorkID is set) the language is ignored and that specific version is returned.

Exceptions
Type Condition
TypeMismatchException

Is thrown if actual type is not assignable to T.

ContentNotFoundException

Is thrown if there is no IContent instance with contentLink as id.

Get<T>(Guid)

Gets the content item represented by the provided GUID.

Declaration
T Get<T>(Guid contentGuid)
    where T : IContentData
Parameters
Type Name Description
System.Guid contentGuid

The content identifier.

Returns
Type Description
T

The requested content item, as the specified type.

Type Parameters
Name Description
T

The type of content to get.

Exceptions
Type Condition
TypeMismatchException

Is thrown if actual type is not assignable to T.

ContentNotFoundException

Is thrown if there is no IContent instance with contentGuid as id.

Get<T>(Guid, LoaderOptions)

Gets the content item represented by the provided GUID given the settings specified by settings, for example Language.

Declaration
T Get<T>(Guid contentGuid, LoaderOptions settings)
    where T : IContentData
Parameters
Type Name Description
System.Guid contentGuid

The content identifier.

LoaderOptions settings

The settings that specifies how content should be loaded.

Returns
Type Description
T

The requested content item, as the specified type.

Type Parameters
Name Description
T

The type of content to get.

Exceptions
Type Condition
TypeMismatchException

Is thrown if actual type is not assignable to T.

ContentNotFoundException

Is thrown if there is no IContent instance with contentGuid as id.

Get<T>(Guid, CultureInfo)

Gets the specific language of content item represented by the provided reference.

Declaration
T Get<T>(Guid contentGuid, CultureInfo language)
    where T : IContentData
Parameters
Type Name Description
System.Guid contentGuid

The content identifier.

System.Globalization.CultureInfo language

The language.

Returns
Type Description
T

The requested content item, as the specified type.

Type Parameters
Name Description
T

The type of content to get.

Exceptions
Type Condition
TypeMismatchException

Is thrown if actual type is not assignable to T.

ContentNotFoundException

Is thrown if there is no IContent instance with contentGuid as id.

GetAncestors(ContentReference)

Retrieves all content items located above the specified content.

Declaration
IEnumerable<IContent> GetAncestors(ContentReference contentLink)
Parameters
Type Name Description
ContentReference contentLink

The reference to the item whose ancestors you want to retrieve.

Returns
Type Description
System.Collections.Generic.IEnumerable<IContent>

A list of all items located above the specified reference.

GetBySegment(ContentReference, String, LoaderOptions)

Gets the child IContentData instance that has a RouteSegment that matches urlSegment.

Declaration
IContent GetBySegment(ContentReference parentLink, string urlSegment, LoaderOptions settings)
Parameters
Type Name Description
ContentReference parentLink

The parent link.

System.String urlSegment

The URL segment.

LoaderOptions settings

The settings to use.

Returns
Type Description
IContent

The content instance that matches urlSegment or null if no match.

Remarks

If LoaderOption contain a LanguageLoaderOption. Then the LanguageLoaderOption is only considered when there are multiple content instances matching the urlSegment. In such cases, content matching the provided language will be preferred ahead of other matches. If none of the content instances matches the language, one of the other instances will be returned.

GetBySegment(ContentReference, String, CultureInfo)

Gets the child IContentData instance that has a RouteSegment that matches urlSegment.

Declaration
IContent GetBySegment(ContentReference parentLink, string urlSegment, CultureInfo language)
Parameters
Type Name Description
ContentReference parentLink

The parent link.

System.String urlSegment

The URL segment.

System.Globalization.CultureInfo language

The preferred language

Returns
Type Description
IContent

The content instance that matches urlSegment or null if no match.

Remarks

The language parameter is only considered when there are multiple content instances matching the urlSegment. In such cases, content matching the provided language will be preferred ahead of other matches. If none of the content instances matches the language, one of the other instances will be returned.

GetChildren<T>(ContentReference)

Gets the children of the content item represented by the provided reference.

Declaration
IEnumerable<T> GetChildren<T>(ContentReference contentLink)
    where T : IContentData
Parameters
Type Name Description
ContentReference contentLink

A reference to the parent whose children should be returned.

Returns
Type Description
System.Collections.Generic.IEnumerable<T>

The children of the specifed parent, as the specified type.

Type Parameters
Name Description
T

The type of children to get.

GetChildren<T>(ContentReference, LoaderOptions)

Gets the children of the content item represented by the provided reference given the settings specified by settings, for example Language.

Declaration
IEnumerable<T> GetChildren<T>(ContentReference contentLink, LoaderOptions settings)
    where T : IContentData
Parameters
Type Name Description
ContentReference contentLink

A reference to the parent whose children should be returned.

LoaderOptions settings

The settings that specifies how content should be loaded.

Returns
Type Description
System.Collections.Generic.IEnumerable<T>

The children of the specifed parent, as the specified type.

Type Parameters
Name Description
T

The type of children to get.

GetChildren<T>(ContentReference, LoaderOptions, Int32, Int32)

Gets the children of the content item represented by the provided reference given the settings specified by settings, for example Language.

Declaration
IEnumerable<T> GetChildren<T>(ContentReference contentLink, LoaderOptions settings, int startIndex, int maxRows)
    where T : IContentData
Parameters
Type Name Description
ContentReference contentLink

A reference to the parent whose children should be returned.

LoaderOptions settings

The settings that specifies how content should be loaded.

System.Int32 startIndex

The index of the first child to return.

System.Int32 maxRows

The max number of children to return.

Returns
Type Description
System.Collections.Generic.IEnumerable<T>

The children of the specifed parent, as the specified type.

Type Parameters
Name Description
T

The type of children to get.

Remarks

This is the overload of GetChildren that supports paging.

GetChildren<T>(ContentReference, CultureInfo)

Gets the children of the content item represented by the provided reference given the language.

Declaration
IEnumerable<T> GetChildren<T>(ContentReference contentLink, CultureInfo language)
    where T : IContentData
Parameters
Type Name Description
ContentReference contentLink

A reference to the parent whose children should be returned.

System.Globalization.CultureInfo language

The language.

Returns
Type Description
System.Collections.Generic.IEnumerable<T>

The children of the specifed parent, as the specified type.

Type Parameters
Name Description
T

The type of children to get.

GetChildren<T>(ContentReference, CultureInfo, Int32, Int32)

Gets the children of the content item represented by the provided reference given the language.

Declaration
IEnumerable<T> GetChildren<T>(ContentReference contentLink, CultureInfo language, int startIndex, int maxRows)
    where T : IContentData
Parameters
Type Name Description
ContentReference contentLink

A reference to the parent whose children should be returned.

System.Globalization.CultureInfo language

The language.

System.Int32 startIndex

The index of the first child to return.

System.Int32 maxRows

The max number of children to return.

Returns
Type Description
System.Collections.Generic.IEnumerable<T>

The children of the specifed parent, as the specified type.

Type Parameters
Name Description
T

The type of children to get.

Remarks

This is the overload of GetChildren that supports paging.

GetDescendents(ContentReference)

Gets references to the descendents of the specified content.

Declaration
IEnumerable<ContentReference> GetDescendents(ContentReference contentLink)
Parameters
Type Name Description
ContentReference contentLink

A reference to the parent whose descendents should be returned.

Returns
Type Description
System.Collections.Generic.IEnumerable<ContentReference>

A list of references to all the descendent of specified content.

GetItems(IEnumerable<ContentReference>, LoaderOptions)

Gets all content items that is represented by the provided references given the settings specified by settings, for example Language.

Declaration
IEnumerable<IContent> GetItems(IEnumerable<ContentReference> contentLinks, LoaderOptions settings)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<ContentReference> contentLinks

A list of references to content that should be fetched.

LoaderOptions settings

The settings that specifies how content should be loaded.

Returns
Type Description
System.Collections.Generic.IEnumerable<IContent>

A list of content for the specifed references.

Remarks

For references that specifies a specific version (that is where WorkID is set) the settings is ignored and that specific version is returned.

If contentLinks contain duplicate entries only one IContent instance is returned for the duplicate entries.

GetItems(IEnumerable<ContentReference>, CultureInfo)

Gets all content items that is represented by the provided references given the language.

Declaration
IEnumerable<IContent> GetItems(IEnumerable<ContentReference> contentLinks, CultureInfo language)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<ContentReference> contentLinks

A list of references to content that should be fetched.

System.Globalization.CultureInfo language

The language.

Returns
Type Description
System.Collections.Generic.IEnumerable<IContent>

A list of content for the specifed references.

Remarks

For references that specifies a specific version (that is where WorkID is set) the language is ignored and that specific version is returned.

If contentLinks contain duplicate entries only one IContent instance is returned for the duplicate entries.

TryGet<T>(ContentReference, out T)

Gets the content item represented by the provided reference.

Declaration
bool TryGet<T>(ContentReference contentLink, out T content)
    where T : IContentData
Parameters
Type Name Description
ContentReference contentLink

The link to the content.

T content

The content with given id or null if content not found or if type is not assignable to T.

Returns
Type Description
System.Boolean

True if content is found or false if content is not found or if found content is of a type not assignable to T.

Type Parameters
Name Description
T

The type of content to get.

TryGet<T>(ContentReference, LoaderOptions, out T)

Gets the content item represented by the provided reference given the settings specified by settings, for example Language.

Declaration
bool TryGet<T>(ContentReference contentLink, LoaderOptions settings, out T content)
    where T : IContentData
Parameters
Type Name Description
ContentReference contentLink

The link to the content.

LoaderOptions settings

The settings that specifies how content should be loaded.

T content

The content with given id or null if content not found or if type is not assignable to T.

Returns
Type Description
System.Boolean

True if content is found or false if content is not found or if found content is of a type not assignable to T.

Type Parameters
Name Description
T

The type of content to get.

TryGet<T>(ContentReference, CultureInfo, out T)

Gets the content item represented by the provided reference given the language.

Declaration
bool TryGet<T>(ContentReference contentLink, CultureInfo language, out T content)
    where T : IContentData
Parameters
Type Name Description
ContentReference contentLink

The link to the content.

System.Globalization.CultureInfo language

The language.

T content

The content with given id or null if content not found or if type is not assignable to T.

Returns
Type Description
System.Boolean

True if content is found or false if content is not found or if found content is of a type not assignable to T.

Type Parameters
Name Description
T

The type of content to get.

Remarks

If the contentLink is a specific version (that is where WorkID is set) the language is ignored and that specific version is returned.

TryGet<T>(Guid, out T)

Gets the content item represented by the provided reference.

Declaration
bool TryGet<T>(Guid contentGuid, out T content)
    where T : IContentData
Parameters
Type Name Description
System.Guid contentGuid

The unique identifier for the content.

T content

The content with given id or null if content not found or if type is not assignable to T.

Returns
Type Description
System.Boolean

True if content is found or false if content is not found or if found content is of a type not assignable to T.

Type Parameters
Name Description
T

The type of content to get.

TryGet<T>(Guid, LoaderOptions, out T)

Gets the content item represented by the provided reference.

Declaration
bool TryGet<T>(Guid contentGuid, LoaderOptions loaderOptions, out T content)
    where T : IContentData
Parameters
Type Name Description
System.Guid contentGuid

The unique identifier for the content.

LoaderOptions loaderOptions

The settings that specifies how the content should be loaded, e.g. the language to get the content in.

T content

The content with given id or null if content not found or if type is not assignable to T.

Returns
Type Description
System.Boolean

True if content is found or false if content is not found or if found content is of a type not assignable to T.

Type Parameters
Name Description
T

The type of content to get.

TryGet<T>(Guid, CultureInfo, out T)

Gets the content item represented by the provided reference given the language.

Declaration
bool TryGet<T>(Guid contentGuid, CultureInfo language, out T content)
    where T : IContentData
Parameters
Type Name Description
System.Guid contentGuid

The guid to the content.

System.Globalization.CultureInfo language

The language.

T content

The content with given id or null if content not found or if type is not assignable to T.

Returns
Type Description
System.Boolean

True if content is found or false if content is not found or if found content is of a type not assignable to T.

Type Parameters
Name Description
T

The type of content to get.

Extension Methods