/// <summary>Returns an object that should be set on the property where this extension is applied. For <see cref="T:System.Windows.ThemeDictionaryExtension" />, this is the URI value for a particular theme dictionary extension.</summary> /// <param name="serviceProvider">An object that can provide services for the markup extension. This service is expected to provide results for <see cref="T:System.Windows.Markup.IXamlTypeResolver" />.</param> /// <returns>The object value to set on the property where the extension is applied. </returns> /// <exception cref="T:System.InvalidOperationException">The <see cref="P:System.Windows.ThemeDictionaryExtension.AssemblyName" /> property is <see langword="null" />. You must set this value during construction or before using the <see cref="M:System.Windows.ThemeDictionaryExtension.ProvideValue(System.IServiceProvider)" /> method.-or- /// <paramref name="serviceProvide" />r is <see langword="null" /> or does not provide a service for <see cref="T:System.Windows.Markup.IXamlTypeResolver" />.-or- /// <paramref name="serviceProvider" /> specifies a target type that does not match <see cref="P:System.Windows.ResourceDictionary.Source" />.</exception> // Token: 0x06000C30 RID: 3120 RVA: 0x0002D554 File Offset: 0x0002B754 public override object ProvideValue(IServiceProvider serviceProvider) { if (string.IsNullOrEmpty(this.AssemblyName)) { throw new InvalidOperationException(SR.Get("ThemeDictionaryExtension_Name")); } IProvideValueTarget provideValueTarget = serviceProvider.GetService(typeof(IProvideValueTarget)) as IProvideValueTarget; if (provideValueTarget == null) { throw new InvalidOperationException(SR.Get("MarkupExtensionNoContext", new object[] { base.GetType().Name, "IProvideValueTarget" })); } object targetObject = provideValueTarget.TargetObject; object targetProperty = provideValueTarget.TargetProperty; ResourceDictionary resourceDictionary = targetObject as ResourceDictionary; PropertyInfo left = targetProperty as PropertyInfo; if (resourceDictionary == null || (targetProperty != null && left != ThemeDictionaryExtension.SourceProperty)) { throw new InvalidOperationException(SR.Get("ThemeDictionaryExtension_Source")); } ThemeDictionaryExtension.Register(resourceDictionary, this._assemblyName); resourceDictionary.IsSourcedFromThemeDictionary = true; return(ThemeDictionaryExtension.GenerateUri(this._assemblyName, SystemResources.ResourceDictionaries.ThemedResourceName, UxThemeWrapper.ThemeName)); }
// Token: 0x06000C35 RID: 3125 RVA: 0x0002D7F0 File Offset: 0x0002B9F0 internal static void OnThemeChanged() { if (ThemeDictionaryExtension._themeDictionaryInfos != null) { for (int i = 0; i < ThemeDictionaryExtension._themeDictionaryInfos.Count; i++) { ThemeDictionaryExtension.ThemeDictionaryInfo themeDictionaryInfo = ThemeDictionaryExtension._themeDictionaryInfos[i]; if (!themeDictionaryInfo.DictionaryReference.IsAlive) { ThemeDictionaryExtension._themeDictionaryInfos.RemoveAt(i); i--; } else { ResourceDictionary resourceDictionary = (ResourceDictionary)themeDictionaryInfo.DictionaryReference.Target; resourceDictionary.Source = ThemeDictionaryExtension.GenerateUri(themeDictionaryInfo.AssemblyName, SystemResources.ResourceDictionaries.ThemedResourceName, UxThemeWrapper.ThemeName); } } } }
// Token: 0x06000C32 RID: 3122 RVA: 0x0002D6A8 File Offset: 0x0002B8A8 internal static Uri GenerateFallbackUri(ResourceDictionary dictionary, string resourceName) { for (int i = 0; i < ThemeDictionaryExtension._themeDictionaryInfos.Count; i++) { ThemeDictionaryExtension.ThemeDictionaryInfo themeDictionaryInfo = ThemeDictionaryExtension._themeDictionaryInfos[i]; if (!themeDictionaryInfo.DictionaryReference.IsAlive) { ThemeDictionaryExtension._themeDictionaryInfos.RemoveAt(i); i--; } else if ((ResourceDictionary)themeDictionaryInfo.DictionaryReference.Target == dictionary) { string themeName = resourceName.Split(new char[] { '/' })[1]; return(ThemeDictionaryExtension.GenerateUri(themeDictionaryInfo.AssemblyName, resourceName, themeName)); } } return(null); }