Class NodeSegment
A Segment representing a contentLink as node in the pagetree when routing. The parameter segment will be created by the RouteParser when the route contains '{node}'.
Implements
Inherited Members
Namespace: EPiServer.Web.Routing.Segments
Assembly: EPiServer.dll
Version: 7.19.2Syntax
public class NodeSegment : SegmentBase, ISegment
Constructors
NodeSegment(String, String, IUrlSegmentRouter, IContentLoader)
Initializes a new instance of the Node segment class.
Declaration
public NodeSegment(string name, string friendlyUrlExtension, IUrlSegmentRouter urlSegmentRouter, IContentLoader contentLoader)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of the segment. |
| System.String | friendlyUrlExtension | he extension used for friendly URL generation. |
| IUrlSegmentRouter | urlSegmentRouter | The router used when resolving nodes. |
| IContentLoader | contentLoader | The content loader. |
NodeSegment(String, String, IUrlSegmentRouter, IContentLoader, UrlResolver)
Initializes a new instance of the Node segment class.
Declaration
public NodeSegment(string name, string friendlyUrlExtension, IUrlSegmentRouter urlSegmentRouter, IContentLoader contentLoader, UrlResolver urlResolver)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of the segment. |
| System.String | friendlyUrlExtension | he extension used for friendly URL generation. |
| IUrlSegmentRouter | urlSegmentRouter | The router used when resolving nodes. |
| IContentLoader | contentLoader | The content loader. |
| UrlResolver | urlResolver | The url resolver to use |
NodeSegment(String, String, IUrlSegmentRouter, ILanguageSegmentMatcher, IContentLoader, IUpdateCurrentLanguage)
Initializes a new instance of the Node segment class.
Declaration
[Obsolete("Use overload without IUpdateCurrentLanguage parameter")]
public NodeSegment(string name, string friendlyUrlExtension, IUrlSegmentRouter urlSegmentRouter, ILanguageSegmentMatcher languageSegment, IContentLoader contentLoader, IUpdateCurrentLanguage updateCurrentLanguage)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name | Name of the segment. |
| System.String | friendlyUrlExtension | he extension used for friendly URL generation. |
| IUrlSegmentRouter | urlSegmentRouter | The router used when resolving nodes. |
| ILanguageSegmentMatcher | languageSegment | The langue segment used. |
| IContentLoader | contentLoader | The content loader. |
| IUpdateCurrentLanguage | updateCurrentLanguage | A handler to update the current language setting. |
Properties
ContentLoader
Gets the content loader.
Declaration
protected IContentLoader ContentLoader { get; }
Property Value
| Type | Description |
|---|---|
| IContentLoader | The content loader. |
IsStartPageResolver
Gets or sets the is start page resolver.
Declaration
public Func<ContentReference, bool> IsStartPageResolver { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Func<ContentReference, System.Boolean> | The is start page resolver. |
LanguageSelectorFactory
Gets or sets the language selector factory.
Declaration
public LanguageSelectorFactory LanguageSelectorFactory { get; set; }
Property Value
| Type | Description |
|---|---|
| LanguageSelectorFactory | The language selector factory. |
UrlSegmentRouter
Gets the URL segment router.
Declaration
protected IUrlSegmentRouter UrlSegmentRouter { get; }
Property Value
| Type | Description |
|---|---|
| IUrlSegmentRouter | The URL segment router. |
Methods
AppendTrailingSlash(RequestContext, RouteValueDictionary)
Will add a trailing slash unless there is a Friendly url extension definied or last content is IBinaryStorable
Declaration
public override bool AppendTrailingSlash(RequestContext requestContext, RouteValueDictionary values)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Web.Routing.RequestContext | requestContext | The request context. |
| System.Web.Routing.RouteValueDictionary | values | The values. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Overrides
GetContentLink(RequestContext, RouteValueDictionary)
Gets the content link from the request context of route values.
Declaration
protected virtual ContentReference GetContentLink(RequestContext requestContext, RouteValueDictionary values)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Web.Routing.RequestContext | requestContext | The request context. |
| System.Web.Routing.RouteValueDictionary | values | The values. |
Returns
| Type | Description |
|---|---|
| ContentReference |
GetIncomingNode(ContentReference, SegmentContext)
Get the last Node within the context.
Declaration
protected virtual ContentReference GetIncomingNode(ContentReference contentLink, SegmentContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| ContentReference | contentLink | contentlink |
| SegmentContext | context | Segment context |
Returns
| Type | Description |
|---|---|
| ContentReference | The last node of the incoming URL |
Remarks
It will recursively traverse the URL to find the last node.
GetLanguage(RequestContext, RouteValueDictionary)
Gets the language.
Declaration
protected virtual string GetLanguage(RequestContext requestContext, RouteValueDictionary values)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Web.Routing.RequestContext | requestContext | The request context. |
| System.Web.Routing.RouteValueDictionary | values | The values. |
Returns
| Type | Description |
|---|---|
| System.String |
GetNextValue(String, SegmentContext)
Finds the next value in the URL by looking for the forward slash character. When the friendly url extension is used, the extension will be removed.
Declaration
protected virtual SegmentPair GetNextValue(string remainingUrl, SegmentContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | remainingUrl | The URL to get next value from. |
| SegmentContext | context | The context. |
Returns
| Type | Description |
|---|---|
| SegmentPair | A SegmentPair containing the next value and the calculated remaining url. |
GetOutgoingUrl(ContentReference, String)
Gets the outgoing URL.
Declaration
protected virtual string GetOutgoingUrl(ContentReference contentLink, string language)
Parameters
| Type | Name | Description |
|---|---|---|
| ContentReference | contentLink | The content link. |
| System.String | language | The language. |
Returns
| Type | Description |
|---|---|
| System.String | The outgoing url for the content reference |
GetOutgoingUrlSegment(ContentReference, String)
Gets the outgoing URL segment for a content item on specified language.
Declaration
protected string GetOutgoingUrlSegment(ContentReference contentLink, string language)
Parameters
| Type | Name | Description |
|---|---|---|
| ContentReference | contentLink | The content link. |
| System.String | language | The language. |
Returns
| Type | Description |
|---|---|
| System.String |
GetRoutedContent(RequestContext, RouteValueDictionary)
Gets the routed content from the request context of route values.
Declaration
protected virtual IContent GetRoutedContent(RequestContext requestContext, RouteValueDictionary values)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Web.Routing.RequestContext | requestContext | The request context. |
| System.Web.Routing.RouteValueDictionary | values | The values. |
Returns
| Type | Description |
|---|---|
| IContent |
GetVirtualPathSegment(RequestContext, RouteValueDictionary)
Gets the string representation of this segments virtual path.
Declaration
public override string GetVirtualPathSegment(RequestContext requestContext, RouteValueDictionary values)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Web.Routing.RequestContext | requestContext | The request |
| System.Web.Routing.RouteValueDictionary | values | Route values |
Returns
| Type | Description |
|---|---|
| System.String | Virtual path from this segment. |
Overrides
Remarks
The returned virtual path will contain language information where applicable.
GetVirtualPathSegment(RequestContext, RouteValueDictionary, HashSet<String>)
Gets the string representation of this segments virtual path.
Declaration
public override string GetVirtualPathSegment(RequestContext requestContext, RouteValueDictionary values, HashSet<string> usedValues)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Web.Routing.RequestContext | requestContext | The request |
| System.Web.Routing.RouteValueDictionary | values | Route values |
| System.Collections.Generic.HashSet<System.String> | usedValues | Route values that are handled and should not be added to the query string. |
Returns
| Type | Description |
|---|---|
| System.String | Virtual path from this segment. |
Overrides
Remarks
The returned virtual path will contain language information where applicable.
PermanentRedirectForDefaultMode(String, SegmentContext)
Does a permanent redirect to redirectUrl if the context is Default.
Declaration
protected virtual bool PermanentRedirectForDefaultMode(string redirectUrl, SegmentContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | redirectUrl | The url to redirect to |
| SegmentContext | context | current request context |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if the request was redirected else false. |
RouteDataMatch(SegmentContext)
Set the node, language and controller value to the segment context.
Declaration
public override bool RouteDataMatch(SegmentContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| SegmentContext | context | The segment context |
Returns
| Type | Description |
|---|---|
| System.Boolean | It will always return true. |
Overrides
Remarks
It will traverse the URL and resolve a node for the last segment. The node will correspond to a page in the page tree. If no node is found, the root node from the IUrlSegmentRouter supplied in the constructor is used.
SetRoutingData(SegmentContext, String, ContentReference)
Set the node, language and controller value to the segment context.
Declaration
protected void SetRoutingData(SegmentContext context, string lang, ContentReference contentLink)
Parameters
| Type | Name | Description |
|---|---|---|
| SegmentContext | context | The segment context. |
| System.String | lang | The language to set. |
| ContentReference | contentLink | The node to set. |