Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Class IContentRepositoryExtension

Extends IContentRepository with some convinent methods.

Inheritance
System.Object
IContentRepositoryExtension
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
Assembly: EPiServer.dll
Version: 11.20.7
Syntax
public static class IContentRepositoryExtension

Methods

Copy(IContentRepository, ContentReference, ContentReference)

Creates a copy of a content object and it's eventual children and adds the new content under the specified destination first ensuring that the current user has read access to the source and create access on the destination.

Declaration
public static ContentReference Copy(this IContentRepository contentRepository, ContentReference source, ContentReference destination)
Parameters
Type Name Description
IContentRepository contentRepository

The IContentRepository instance to extend.

ContentReference source

The content that should be copied.

ContentReference destination

The destination where the page will be copied as a child to.

Returns
Type Description
ContentReference

A reference to the new copy of the content.

Remarks

If the user has publishing rights on the destination the new content will be published immediately.

CreateLanguageBranch<T>(IContentRepository, ContentReference, ILanguageSelector)

Creates a new language branch for a content item in the specified language.

Declaration
public static T CreateLanguageBranch<T>(this IContentRepository contentRepository, ContentReference contentLink, ILanguageSelector languageSelector)
    where T : IContentData
Parameters
Type Name Description
IContentRepository contentRepository

The content repository.

ContentReference contentLink

The link to the content to create a language branch for.

ILanguageSelector languageSelector

The selector.

Returns
Type Description
T

An IContent object for the newly created content in the specified language.

Type Parameters
Name Description
T

The type of content to create.

Remarks

Access checks are performed during Save. CreateLanguageBranch method returns not persisted in-memory instance.

Delete(IContentRepository, ContentReference, Boolean)

Deletes a content from the repository first ensuring that the current user meets the minimal access right requirements.

Declaration
public static void Delete(this IContentRepository repository, ContentReference contentLink, bool forceDelete)
Parameters
Type Name Description
IContentRepository repository

The repository.

ContentReference contentLink

The content link.

System.Boolean forceDelete

If set to true, deletes the content even if it is being referenced by other content.

Move(IContentRepository, ContentReference, ContentReference)

Moves content from it's current location to another position in the structure first ensuring that the current user has the minimal access rights required at the destination.

Declaration
public static ContentReference Move(this IContentRepository contentRepository, ContentReference contentLink, ContentReference destination)
Parameters
Type Name Description
IContentRepository contentRepository

The IContentRepository instance to extend.

ContentReference contentLink

The content that should be moved.

ContentReference destination

The destination where the content will be moved as a child to.

Returns
Type Description
ContentReference

A ContentReference to the moved content.

Remarks

The user will always need at least Create access at the destination and if the page is published the user will Publish access as well unless the destination is the wastebasket.

MoveToWastebasket(IContentRepository, ContentReference)

Moves content from it's current location to Wastebasket position in the structure with the current user name

Declaration
public static void MoveToWastebasket(this IContentRepository contentRepository, ContentReference contentLink)
Parameters
Type Name Description
IContentRepository contentRepository

The content repository.

ContentReference contentLink

The content link.

Publish(IContentRepository, IContent)

Publishes a content item to the repository first ensuring that the current user meets the mininum access rights requirements.

Declaration
public static ContentReference Publish(this IContentRepository repository, IContent content)
Parameters
Type Name Description
IContentRepository repository

The IContentRepository instance to extend.

IContent content

An IContent object containing all the data that should be saved and published.

Returns
Type Description
ContentReference

A ContentReference to the published content version.

Remarks

The minimum access rights required is dependent on if the content is new and if the content is modifed or not.

Publish(IContentRepository, IContent, AccessLevel)

Publishes a content item to the repository first ensuring that the current user meets the provided access rights requirements.

Declaration
public static ContentReference Publish(this IContentRepository repository, IContent content, AccessLevel access)
Parameters
Type Name Description
IContentRepository repository

The IContentRepository instance to extend.

IContent content

An IContent object containing all the data that should be saved.

AccessLevel access

The minimum access level that the current user must have to publish the content.

Returns
Type Description
ContentReference

A ContentReference to the published content version.

Save(IContentRepository, IContent)

Saves a content to the repository first ensuring that the current user meets the mininum access rights requirements.

Declaration
public static ContentReference Save(this IContentRepository repository, IContent content)
Parameters
Type Name Description
IContentRepository repository

The IContentRepository instance to extend.

IContent content

An IContent object containing all the data that should be saved.

Returns
Type Description
ContentReference

A ContentReference to the saved content version.

Remarks

The minimum access rights required will be dependent on the current status of the content.

Save(IContentRepository, IContent, SaveAction)

Saves a content to the repository with the provided save action performed first ensuring that the current user meets the mininum access rights requirements.

Declaration
public static ContentReference Save(this IContentRepository repository, IContent content, SaveAction action)
Parameters
Type Name Description
IContentRepository repository

The IContentRepository instance to extend.

IContent content

An IContent object containing all the data that should be saved.

SaveAction action

The exact SaveAction that should be performed.

Returns
Type Description
ContentReference

A ContentReference to the saved content version.

Remarks

The minimum access rights required is dependent on the current status of the content and the exact action that should be performed.

Save(IContentRepository, IContent, AccessLevel)

Saves a content to the repository first ensuring that the current user meets the provided access rights requirements.

Declaration
public static ContentReference Save(this IContentRepository repository, IContent content, AccessLevel access)
Parameters
Type Name Description
IContentRepository repository

The IContentRepository instance to extend.

IContent content

An IContent object containing all the data that should be saved.

AccessLevel access

The minimum access level that the current user must have to save the content.

Returns
Type Description
ContentReference

A ContentReference to the saved content version.