Ejemplo n.º 1
0
        public static IEnumerable <Uri> FindReferencedDictionaries(DocumentCompositeNode node)
        {
            HashSet <Uri> uris = new HashSet <Uri>();
            IPropertyId   resourcesProperty = node.Type.Metadata.ResourcesProperty;

            if (resourcesProperty != null)
            {
                DocumentCompositeNode item = node.Properties[resourcesProperty] as DocumentCompositeNode;
                if (item != null)
                {
                    node = item;
                }
            }
            if (PlatformTypes.ResourceDictionary.IsAssignableFrom(node.Type))
            {
                ResourceNodeHelper.FindReferencedDictionariesInternal(node, uris);
            }
            return(uris);
        }
Ejemplo n.º 2
0
        private static void FindReferencedDictionaryFromSource(DocumentCompositeNode resourceDictionaryNode, HashSet <Uri> dictionaries)
        {
            DocumentCompositeNode rootNode;
            Uri uriValue = resourceDictionaryNode.GetUriValue(KnownProperties.ResourceDictionarySourceProperty);

            if (uriValue != null)
            {
                uriValue = resourceDictionaryNode.Context.MakeDesignTimeUri(uriValue);
                if (uriValue != null && uriValue.IsAbsoluteUri && !dictionaries.Contains(uriValue))
                {
                    dictionaries.Add(uriValue);
                    DocumentCompositeNode documentCompositeNode = null;
                    IDocumentRoot         documentRoot          = null;
                    try
                    {
                        documentRoot = resourceDictionaryNode.Context.GetDocumentRoot(uriValue.OriginalString);
                        if (documentRoot != null)
                        {
                            if (documentRoot.IsEditable)
                            {
                                rootNode = documentRoot.RootNode as DocumentCompositeNode;
                            }
                            else
                            {
                                rootNode = null;
                            }
                            documentCompositeNode = rootNode;
                        }
                    }
                    catch (IOException oException)
                    {
                    }
                    catch (NotSupportedException notSupportedException)
                    {
                    }
                    if (documentCompositeNode != null && PlatformTypes.ResourceDictionary.IsAssignableFrom(documentCompositeNode.Type))
                    {
                        ResourceNodeHelper.FindReferencedDictionariesInternal(documentCompositeNode, dictionaries);
                    }
                }
            }
        }