public static void RunWithWebCultureScope(SPWeb web, CodeToRunWithCultureScope code) { if (web == null) { throw new ArgumentNullException("web"); } if (code == null) { throw new ArgumentNullException("code"); } RunWithCultureScope(delegate { Thread.CurrentThread.CurrentCulture = web.Locale; Thread.CurrentThread.CurrentUICulture = web.UICulture; code(); }); }
public static void RunWithCultureScope(CodeToRunWithCultureScope code) { if (code == null) { throw new ArgumentNullException("code"); } CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; CultureInfo currentUICulture = Thread.CurrentThread.CurrentUICulture; try { code(); } catch { throw; } finally { Thread.CurrentThread.CurrentCulture = currentCulture; Thread.CurrentThread.CurrentUICulture = currentUICulture; } }