Esempio n. 1
0
        private DocumentCompositeNode FindResourceInRelatedDocument(IDocumentRootResolver documentRootResolver, DocumentNode keyNode, ICollection <DocumentCompositeNode> resourcesHostNodePath, ICollection <IDocumentRoot> relatedRoots, ResourceSite.ResourceDictionaryLink container, DocumentNode rootNode)
        {
            IDocumentRoot documentRoot = rootNode.DocumentRoot;

            for (ResourceSite.ResourceDictionaryLink i = container; i != null; i = i.Container)
            {
                if (i.DocumentRoot == documentRoot)
                {
                    return(null);
                }
            }
            ResourceSite          resourceSite          = new ResourceSite(rootNode);
            DocumentCompositeNode documentCompositeNode = resourceSite.FindResource(documentRootResolver, keyNode, resourcesHostNodePath, relatedRoots, new ResourceSite.ResourceDictionaryLink(container, documentRoot), -1, null);

            if (documentCompositeNode != null && relatedRoots != null)
            {
                relatedRoots.Add(documentRoot);
            }
            return(documentCompositeNode);
        }
Esempio n. 2
0
 public ResourceDictionaryLink(ResourceSite.ResourceDictionaryLink container, IDocumentRoot documentRoot)
 {
     this.container    = container;
     this.documentRoot = documentRoot;
 }
Esempio n. 3
0
        private DocumentCompositeNode FindResource(IDocumentRootResolver documentRootResolver, DocumentNode keyNode, ICollection <DocumentCompositeNode> resourcesHostNodePath, ICollection <IDocumentRoot> relatedRoots, ResourceSite.ResourceDictionaryLink container, int numberOfChildrenToSearch, ICollection <string> warnings)
        {
            if (resourcesHostNodePath != null)
            {
                resourcesHostNodePath.Add(this.resourcesHost.HostNode);
            }
            DocumentCompositeNode resources = this.resourcesHost.Resources;

            if (resources == null)
            {
                return(null);
            }
            DocumentCompositeNode documentCompositeNode = ResourceSite.FindResource(keyNode, resources, numberOfChildrenToSearch);

            if (documentCompositeNode != null)
            {
                return(documentCompositeNode);
            }
            if (documentRootResolver == null)
            {
                return(null);
            }
            if (resources.TypeResolver.ResolveProperty(KnownProperties.ResourceDictionaryMergedDictionariesProperty) != null)
            {
                DocumentCompositeNode item = resources.Properties[KnownProperties.ResourceDictionaryMergedDictionariesProperty] as DocumentCompositeNode;
                if (item != null)
                {
                    for (int i = item.Children.Count - 1; i >= 0; i--)
                    {
                        DocumentCompositeNode item1 = item.Children[i] as DocumentCompositeNode;
                        if (item1 != null)
                        {
                            DocumentNode resolvedDocumentRootForSourceUri = this.GetResolvedDocumentRootForSourceUri(documentRootResolver, item1, warnings);
                            if (resolvedDocumentRootForSourceUri == null || !PlatformTypes.ResourceDictionary.IsAssignableFrom(resolvedDocumentRootForSourceUri.Type))
                            {
                                documentCompositeNode = ResourceSite.FindResource(keyNode, item1, -1);
                                if (documentCompositeNode != null)
                                {
                                    return(documentCompositeNode);
                                }
                            }
                            else
                            {
                                documentCompositeNode = this.FindResourceInRelatedDocument(documentRootResolver, keyNode, resourcesHostNodePath, relatedRoots, container, resolvedDocumentRootForSourceUri);
                                if (documentCompositeNode != null)
                                {
                                    return(documentCompositeNode);
                                }
                            }
                        }
                    }
                }
            }
            if (resources.TypeResolver.ResolveProperty(KnownProperties.ResourceDictionarySourceProperty) != null)
            {
                DocumentNode documentNode = this.GetResolvedDocumentRootForSourceUri(documentRootResolver, resources, warnings);
                if (documentNode != null && PlatformTypes.ResourceDictionary.IsAssignableFrom(documentNode.Type))
                {
                    return(this.FindResourceInRelatedDocument(documentRootResolver, keyNode, resourcesHostNodePath, relatedRoots, container, documentNode));
                }
            }
            return(null);
        }