|
using System;
using System.Globalization;
using System.Threading;
namespace Tests
{
/// <summary>
/// </summary>
/// <remarks>
/// </remarks>
internal class SwitchCultureInfo: IDisposable
{
private readonly CultureInfo _original;
/// <summary>
/// Changes the current CultureInfo
/// </summary>
/// <param name="newCultureInfo"></param>
public SwitchCultureInfo(CultureInfo newCultureInfo)
{
_original = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = newCultureInfo;
}
/// <summary>
/// Changes the current CultureInfo
/// </summary>
/// <param name="cultureName"></param>
public SwitchCultureInfo(string cultureName) :
this(new CultureInfo(cultureName))
{}
/// <summary>
/// Restores the CultureInfo buffered in the constructor.
/// </summary>
public void Dispose()
{
Thread.CurrentThread.CurrentCulture = _original;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
My name is Idalgo Cantelli. I'm a software developer skilled in .Net technologies. I work with .Net since February, 2002. I also have a strong experience as a technical trainer, having taught in more than thirty classroom courses. I'm MCTS and MCPD-EAD on .Net 2.0, planning an upgrade to 3.5.