Delete a language branch for a page.

Namespace:  EPiServer.Core
Assembly:  EPiServer (in EPiServer.dll) Version: 5.2.375.236

Syntax

C#
public virtual void DeleteLanguageBranch(
	PageReference pageLink,
	string languageBranch
)

Parameters

pageLink
Type: EPiServer.Core..::.PageReference
The link to the page which will be deleted
languageBranch
Type: System..::.String
The language branch to delete

Implements

IPageStore..::.DeleteLanguageBranch(PageReference, String)

Remarks

If delete is to be supported this method needs to be overriden.

Note that you cannot delete the master language branch.

Examples

The following code sample is an implementation of DeleteLanguageBranch() for XmlPageProvider.
CopyC#
public override void DeleteLanguageBranch(PageReference pageLink, string languageBranch)
{
    List<string> existingLanguages = new List<string>();

    //Make a request for the page in the specified language
    XElement languageNode = GetPageNode(pageLink, new LanguageSelector(languageBranch), out existingLanguages);
    if (languageNode == null)
    {
        throw new PageNotFoundException(pageLink);
    }

    //See if returned page element is in specified language (it might not be the case since GetPageNode always return a pagenode if the page
    //exist. In case it does not exist on specified language master language branch is returned).
    string returnedBranch = (from language in languageNode.Elements("property").Attributes("name")
                             where String.Equals(language.Value, "PageLanguageBranch")
                             select language.Parent.Value).SingleOrDefault<string>();
    if (!String.Equals(returnedBranch, languageBranch, StringComparison.OrdinalIgnoreCase))
    {
        throw new InvalidOperationException(String.Format("Page {0} does not exist on language {1}", pageLink.ToString(), languageBranch));
    }

    //Check that it is not the master language branch
    string masterLanugageBranch = (from masterLanguage in languageNode.Elements("property").Attributes("name")
                            where String.Equals(masterLanguage.Value, "PageMasterLanguageBranch")
                            select masterLanguage.Parent.Value).SingleOrDefault<string>();
    if (String.Equals(masterLanugageBranch, languageBranch, StringComparison.OrdinalIgnoreCase))
    {
        throw new InvalidOperationException("Cannot delete master language branch. Call Delete instead to delete a page for all languages");
    }

    languageNode.Remove();
    XmlPages.Save(_filePath);
}

Exceptions

ExceptionCondition
System..::.NotImplementedException Thrown if the Page Provider indicates support for Delete specific Language with the Capabilities property, but does not override Move method.
System..::.NotSupportedException Thrown if the Page Provider does not support Delete specific Language.

See Also