Ejemplo n.º 1
0
        public void EnsureThemePartLoaded(Assembly assembly)
        {
            var name = ThemePart.GetName(assembly);

            if (ThemeParts.TryGetValue(name, out var themeParts) == false)
            {
                return;
            }

            var newXamlResources = new List <XamlResourceInfo>();

            foreach (var themePart in themeParts.ToList())
            {
                themePart.ResolveDependency(assembly);

                if (themePart.HasDependencies == false)
                {
                    var themePartAssembly = themePart.EnsureThemePartAssembly();

                    if (themePartAssembly != null)
                    {
                        LoadThemeAssembly(themePartAssembly, newXamlResources);
                    }

                    ThemeParts.RemoveValue(name, themePart);
                }
            }

            if (newXamlResources.Count > 0)
            {
                OnXamlResourceLoading(new XamlResourceLoadingEventArgs(newXamlResources));
            }
        }
Ejemplo n.º 2
0
        internal void LoadThemeAssemblies(IEnumerable <Assembly> assemblies)
        {
            var newXamlResources = new List <XamlResourceInfo>();

            foreach (var assembly in assemblies)
            {
                try
                {
                    foreach (var themePart in LoadThemeParts(assembly))
                    {
                        if (themePart.HasDependencies)
                        {
                            foreach (var themePartAssemblyDependency in themePart.Dependencies)
                            {
                                ThemeParts.AddValue(themePartAssemblyDependency, themePart);
                            }
                        }
                        else
                        {
                            var themePartAssembly = themePart.EnsureThemePartAssembly();

                            if (themePartAssembly != null)
                            {
                                LoadThemeAssembly(themePartAssembly, newXamlResources);
                            }
                        }
                    }

                    LoadThemeAssembly(assembly, newXamlResources);
                }
                catch (Exception e)
                {
                    LogService.LogError(e);
                }
            }

            try
            {
                foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
                {
                    var name = ThemePart.GetName(assembly);

                    if (ThemeParts.TryGetValue(name, out var themeParts))
                    {
                        foreach (var themePart in themeParts.ToList())
                        {
                            themePart.ResolveDependency(assembly);

                            if (themePart.HasDependencies == false)
                            {
                                var themePartAssembly = themePart.EnsureThemePartAssembly();

                                if (themePartAssembly != null)
                                {
                                    LoadThemeAssembly(themePartAssembly, newXamlResources);
                                }

                                ThemeParts.RemoveValue(name, themePart);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                LogService.LogError(e);
            }

            if (newXamlResources.Count > 0)
            {
                OnXamlResourceLoading(new XamlResourceLoadingEventArgs(newXamlResources));
            }
        }