Show / Hide Table of Contents

Class CultureSettingHelper

Context class that will remember the current culture settings, and reset them when it is disposed.

Inheritance
object
CultureSettingHelper
Implements
IDisposable
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
Namespace: SuperOffice.Globalization
Assembly: SoCore.dll
Syntax
public sealed class CultureSettingHelper : IDisposable
Examples

This class is meant for a using() clause, when you temporarily need to set the current culture to something else than the default, and want to go back afterwards.

// in this example, the culture name is known
using( new CultureSettingHelper( myCultureName ))	// set both current and currentUI cultures on current thread
{
	// culture-dependent processing
}
// culture has been restored

Constructors

CultureSettingHelper()

Save the current culture settings, and do not change them

Declaration
public CultureSettingHelper()

CultureSettingHelper(CultureInfo)

Save the current culture settings, and set both the CurrentCulture and CurrentUICulture on the current thread to the new value.

Declaration
public CultureSettingHelper(CultureInfo newCurrentCulture)
Parameters
Type Name Description
CultureInfo newCurrentCulture

Culture to set (both current and currentUI)

CultureSettingHelper(CultureInfo, CultureInfo)

Save the current culture settings, and set both the CurrentCulture and CurrentUICulture on the current thread to the new values.

Declaration
public CultureSettingHelper(CultureInfo newCurrentCulture, CultureInfo newCurrentUICulture)
Parameters
Type Name Description
CultureInfo newCurrentCulture

Culture to set

CultureInfo newCurrentUICulture

UI Culture to set

CultureSettingHelper(string)

Save the current culture settings, and set both the CurrentCulture and CurrentUICulture on the current thread to the new value.

Declaration
public CultureSettingHelper(string newCultureName)
Parameters
Type Name Description
string newCultureName

CultureSettingHelper(string, string)

Save the current culture settings, and set both the CurrentCulture and CurrentUICulture on the current thread to the new values.

Declaration
public CultureSettingHelper(string newCultureName, string newUICultureName)
Parameters
Type Name Description
string newCultureName
string newUICultureName

Methods

Dispose()

Reset the culture to the saved settings

Declaration
public void Dispose()

Implements

IDisposable

Extension Methods

EnumUtil.MapEnums<From, To>(From)
Converters.MapEnums<From, To>(From)
ObjectExtensions.AssignByReflection<T>(T, T)
ObjectExtensions.GraphCopy<T>(T)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top