예제 #1
0
 private Culture(CultureInfo culture, CulturePlacement placement)
 {
     if (placement.HasFlag(CulturePlacement.ThreadCulture))
     {
         _previousCulture = Thread.CurrentThread.CurrentCulture;
         Thread.CurrentThread.CurrentCulture = culture;
     }
     if (placement.HasFlag(CulturePlacement.ThreadUiCulture))
     {
         _previousUiCulture = Thread.CurrentThread.CurrentUICulture;
         Thread.CurrentThread.CurrentUICulture = culture;
     }
 }
예제 #2
0
 /// <summary>
 /// Switch to the culture corresponding to the ietf language tag until this object is disposed
 /// </summary>
 /// <param name="ietfLanguageTag">An identifier in the form of xx-XX where 'xx' is the language identifier and 'XX' is the country identifier</param>
 /// <param name="placement">Specify whether to change the CurrentCulture, the CurrentUiCulture, or both. Default is both</param>
 /// <returns>Culture disposable object</returns>
 public static IDisposable SwitchTo(string ietfLanguageTag, CulturePlacement placement = CulturePlacement.Both)
 {
     try
     {
         var culture = CultureInfo.GetCultureInfoByIetfLanguageTag(ietfLanguageTag);
         return(SwitchTo(culture, placement));
     }
     catch (CultureNotFoundException)
     {
         Assert.Fail("Culture {0} is not a known culture");
         return(null);                // will never be hit
     }
 }
예제 #3
0
 /// <summary>
 /// Switch to the culture corresponding to the ietf language tag until this object is disposed
 /// </summary>
 /// <param name="culture">A CultureInfo object</param>
 /// <param name="placement">Specify whether to change the CurrentCulture, the CurrentUiCulture, or both. Default is both</param>
 /// <returns>Culture disposable object</returns>
 public static IDisposable SwitchTo(CultureInfo culture, CulturePlacement placement = CulturePlacement.Both)
 {
     return(new Culture(culture, placement));
 }