November Happy Hour will be moved to Thursday December 5th.

Class ProviderBasedLocalizationService

Provider based implementation of LocalizationService. Uses LocalizationProviders to load localized resources.

Inheritance
System.Object
ProviderBasedLocalizationService
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: 11.20.7
Syntax
[ServiceConfiguration(typeof(LocalizationService), Lifecycle = ServiceInstanceScope.Singleton, FactoryMember = "CreateLocalizationService")]
[InitializableModule]
public class ProviderBasedLocalizationService : LocalizationService, IConfigurableModule, IInitializableModule

Constructors

ProviderBasedLocalizationService()

Initializes a new instance of the ProviderBasedLocalizationService class.

Declaration
public ProviderBasedLocalizationService()

ProviderBasedLocalizationService(ResourceKeyHandler)

Initializes a new instance of the ProviderBasedLocalizationService class.

Declaration
public ProviderBasedLocalizationService(ResourceKeyHandler keyHandler)
Parameters
Type Name Description
ResourceKeyHandler keyHandler

The handler used to manipulate resource keys.

Properties

AvailableLocalizations

Gets all available localizations that the LocalizationService has knowledge of.

Declaration
public override IEnumerable<CultureInfo> AvailableLocalizations { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<System.Globalization.CultureInfo>
Overrides

ProviderList

Gets a list of the current set of LocalizationProvider that are used by the ProviderBasedLocalizationService.

Declaration
public IEnumerable<LocalizationProvider> ProviderList { get; }
Property Value
Type Description
System.Collections.Generic.IEnumerable<LocalizationProvider>
Remarks

Providers are processed in prioritized order from first to last and will return localized strings from the first provider that returns a value.

Providers

Gets a list of the current set of LocalizationProvider that are used by the ProviderBasedLocalizationService.

Declaration
[Obsolete("This property has been deprecated due to thread issues. Add additional providers by using methods AddProvider or InsertProvider. Inspect the current set of providers by calling ProviderList.", true)]
public IList<LocalizationProvider> Providers { get; protected set; }
Property Value
Type Description
System.Collections.Generic.IList<LocalizationProvider>

Methods

AddProvider(LocalizationProvider)

Adds a LocalizationProvider to the service at the end of the provider list.

Declaration
public void AddProvider(LocalizationProvider provider)
Parameters
Type Name Description
LocalizationProvider provider

The provider that should be added.

ConfigureContainer(ServiceConfigurationContext)

Configure the IoC container before initialization.

Declaration
public void ConfigureContainer(ServiceConfigurationContext context)
Parameters
Type Name Description
ServiceConfigurationContext context

The context on which the container can be accessed.

CreateLocalizationService(ResourceKeyHandler, LocalizationOptions, IServiceLocator)

Unsupported INTERNAL API! Not covered by semantic versioning; might change without notice.

Declaration
public static LocalizationService CreateLocalizationService(ResourceKeyHandler keyHandler, LocalizationOptions localizationOptions, IServiceLocator serviceLocator)
Parameters
Type Name Description
ResourceKeyHandler keyHandler
LocalizationOptions localizationOptions
IServiceLocator serviceLocator
Returns
Type Description
LocalizationService

GetAllStringsByCulture(String, String[], CultureInfo)

Gets all localized strings for the specified culture below the specified key.

Declaration
protected override IEnumerable<ResourceItem> GetAllStringsByCulture(string originalKey, string[] normalizedKey, CultureInfo culture)
Parameters
Type Name Description
System.String originalKey

The original key that was passed into any GetString method.

System.String[] normalizedKey

The originalKey normalized and split into an array

System.Globalization.CultureInfo culture

The requested culture for the localized strings.

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

All localized strings below the specified key.

Overrides
See Also
GetStringByCulture(System.String, System.Globalization.CultureInfo)

Initialize(InitializationEngine)

Declaration
public void Initialize(InitializationEngine context)
Parameters
Type Name Description
InitializationEngine context

InsertProvider(LocalizationProvider)

Adds a LocalizationProvider to the service at the to of the provider list.

Declaration
public void InsertProvider(LocalizationProvider provider)
Parameters
Type Name Description
LocalizationProvider provider

The provider that should be added.

LoadString(String[], String, CultureInfo)

Gets the localized string for the specified key in the specified culture.

Declaration
protected override string LoadString(string[] normalizedKey, string originalKey, CultureInfo culture)
Parameters
Type Name Description
System.String[] normalizedKey

The originalKey normalized and split into an array

System.String originalKey

The original key that was passed into any GetString method.

System.Globalization.CultureInfo culture

The requested culture for the localized string.

Returns
Type Description
System.String

A localized string or null if no resource is found for the given key and culture.

Overrides
See Also
GetStringByCulture(System.String, System.Globalization.CultureInfo)

RemoveProvider(String)

Removes an existing LocalizationProvider from the list of providers for this service.

Declaration
public void RemoveProvider(string name)
Parameters
Type Name Description
System.String name

The name of the provider to remove.

Exceptions
Type Condition
System.ArgumentException

Thrown if no provider with the given name has been added to the service.

Uninitialize(InitializationEngine)

Declaration
public void Uninitialize(InitializationEngine context)
Parameters
Type Name Description
InitializationEngine context

Implements

Extension Methods