/// <summary> /// Gets the UI culture set for the object. /// </summary> /// <returns> /// A <see cref="CultureInfo"/> or null if no explicit value is set for the object. /// </returns> public CultureInfo GetUICulture() { var obj = Object; if (obj == null) { return(null); } CultureInfo result; if (obj.CheckAccess()) { result = LocalizationScope.GetUICulture(obj); } else { result = (CultureInfo)obj.Dispatcher.Invoke(new DispatcherOperationCallback(x => LocalizationScope.GetUICulture((DependencyObject)x)), obj); } if (result == null) { // Get the culture of the UI thread in case the current thread is different result = obj.Dispatcher.Thread.CurrentUICulture; } return(result); }
/// <summary> /// Gets the <see cref="ResourceManager"/> set for the object. /// </summary> /// <returns> /// A <see cref="ResourceManager"/> or null if no explicit value is set for the object. /// </returns> public ResourceManager GetResourceManager() { var obj = Object; if (obj == null) { return(null); } ResourceManager result; if (obj.CheckAccess()) { result = LocalizationScope.GetResourceManager(obj); } else { result = (ResourceManager)obj.Dispatcher.Invoke(new DispatcherOperationCallback(x => LocalizationScope.GetResourceManager((DependencyObject)x)), obj); } if (result == null) { result = LocalizationManager.DefaultResourceManager; } return(result); }