Class ResourceKeyHandler

Performs different operations on resource keys for LocalizationService.

Inheritance
System.Object
ResourceKeyHandler
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.Framework.Localization
Assembly: EPiServer.Framework.dll
Version: 8.11.0
Syntax
[ServiceConfiguration]
public class ResourceKeyHandler

Constructors

ResourceKeyHandler()

Initializes a new instance of the ResourceKeyHandler class.

Declaration
public ResourceKeyHandler()

ResourceKeyHandler(ServiceAccessor<HttpContextBase>)

Initializes a new instance of the ResourceKeyHandler class.

Declaration
public ResourceKeyHandler(ServiceAccessor<HttpContextBase> contextLoader)
Parameters
Type Name Description
ServiceAccessor<System.Web.HttpContextBase> contextLoader

The method that will provide the current HttpContext. If null, the System.Web.HttpContext.Current will be used.

Fields

ComplexResourceKeyIdentifier

The character that if present at the start of the resource key, identifies that it is a key that is made up of multiple sections.

Declaration
public static readonly char ComplexResourceKeyIdentifier
Field Value
Type Description
System.Char

ComplexResourceKeySeparator

The character that separates the different parts of a complex key.

Declaration
public static readonly char ComplexResourceKeySeparator
Field Value
Type Description
System.Char

ContextBasedResourceKeyIdentifier

The character that if present at the start of the resource key, identifies that it is a context based key that should be resolved based on the current request path.

Declaration
public static readonly char ContextBasedResourceKeyIdentifier
Field Value
Type Description
System.Char

Methods

IsComplexKey(String)

Determines whether the specified key is a complex resource key, i.e. made up by multiple sections.

Declaration
public virtual bool IsComplexKey(string key)
Parameters
Type Name Description
System.String key

The key to test.

Returns
Type Description
System.Boolean

true if the specified key is a complex key; otherwise, false.

JoinKey(String, String[])

Joins a normalized key back into a single key string.

Declaration
public virtual string JoinKey(string originalKey, string[] normalizedKey)
Parameters
Type Name Description
System.String originalKey
System.String[] normalizedKey
Returns
Type Description
System.String

NormalizeKey(String)

Normalizes the resource key to an array of key parts split on forward slash (/). If the key starts with a hash (#), it will use the current request path to resolve the key.

Declaration
public virtual string[] NormalizeKey(string resourceKey)
Parameters
Type Name Description
System.String resourceKey

The resource key to normalize. The key must start with '/' or '#' for the key to be normalized.

Returns
Type Description
System.String[]

An normalized array with key parts.

Remarks

Raises the KeyNormalized event once normalization is complete. This event allows for external code to modify the standard normalization behavior.

ResolveContextBasedKey(String)

Resolves a resource key based on the current request path.

Declaration
public virtual string ResolveContextBasedKey(string resourceKey)
Parameters
Type Name Description
System.String resourceKey

The resource key to resolve.

Returns
Type Description
System.String

A key that has the current request path added to the beginning of the key.

TransformResourceKey(String)

Transforms a resource key that has the character "." as separator to a key with slashes as separator.

Declaration
public virtual string TransformResourceKey(string resourceKeyWithDotSeparator)
Parameters
Type Name Description
System.String resourceKeyWithDotSeparator

A resource key with dot as separator.

Returns
Type Description
System.String

A resource key with slash as separator.

Examples

From A.Resource.Key to /A/Resource/Key