Esempio n. 1
0
        private ThemeContentProvider.SystemThemeContentProvider GetCachedThemeContent(Dictionary <ThemeContentProvider.PlatformSpecificDocumentReference, ThemeContentProvider.SystemThemeContentProvider> themeCache, ThemeManager manager, IProjectContext projectContext, DocumentReference reference, IAssembly themeAssembly, string themeAssemblyPath, ITextBufferService textBufferService)
        {
            ThemeContentProvider.PlatformSpecificDocumentReference key = new ThemeContentProvider.PlatformSpecificDocumentReference(reference, projectContext != null ? projectContext.TargetFramework : (FrameworkName)null);
            ThemeContentProvider.SystemThemeContentProvider        themeContentProvider;
            if (!themeCache.TryGetValue(key, out themeContentProvider))
            {
                Encoding    encoding;
                ITextBuffer textBuffer = themeAssembly != null?ThemeManager.LoadResource(themeAssembly, themeAssemblyPath, textBufferService, out encoding) : ThemeContentProvider.LoadReference(reference, textBufferService, out encoding);

                IDocumentLocator documentLocator = DocumentReferenceLocator.GetDocumentLocator(reference);
                IDocumentContext userContext     = projectContext == null ? (IDocumentContext)null : (IDocumentContext) new DocumentContext(projectContext, documentLocator);
                XamlDocument     theme           = manager.GetTheme(documentLocator, themeAssembly != null, userContext, textBuffer, encoding);
                if (theme != null)
                {
                    bool flag1 = false;
                    try
                    {
                        if (projectContext != null)
                        {
                            if (!projectContext.IsCapabilitySet(PlatformCapability.IsWpf))
                            {
                                if (themeAssembly != null)
                                {
                                    bool flag2 = false;
                                    foreach (IAssembly assembly in (projectContext.Platform.Metadata as PlatformTypes).DefaultAssemblyReferences)
                                    {
                                        if (assembly == themeAssembly)
                                        {
                                            flag2 = true;
                                            break;
                                        }
                                    }
                                    if (flag2)
                                    {
                                        flag1 = true;
                                        AnimationEditor.ConvertFromToAnimations(theme.RootNode);
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                        if (flag1)
                        {
                            theme = manager.GetTheme(documentLocator, themeAssembly != null, userContext, textBuffer, encoding);
                        }
                    }
                    themeContentProvider = new ThemeContentProvider.SystemThemeContentProvider(this.designerContext, theme);
                    themeCache[key]      = themeContentProvider;
                }
            }
            return(themeContentProvider);
        }
Esempio n. 2
0
        private DocumentNode GetResourceInternal(Dictionary <ThemeContentProvider.PlatformSpecificDocumentReference, ThemeContentProvider.SystemThemeContentProvider> themeCache, ThemeManager manager, IProjectContext projectContext, DocumentReference theme, IAssembly themeAssembly, string themeAssemblyPath, object resourceKey, out IList <DocumentCompositeNode> auxillaryResources)
        {
            auxillaryResources = (IList <DocumentCompositeNode>)null;
            ThemeContentProvider.SystemThemeContentProvider cachedThemeContent = this.GetCachedThemeContent(themeCache, manager, projectContext, theme, themeAssembly, themeAssemblyPath, this.designerContext.TextBufferService);
            DocumentNode  documentNode = (DocumentNode)null;
            List <string> resolvedUris = new List <string>();

            if (cachedThemeContent != null)
            {
                documentNode = ThemeContentProvider.FindResource((ResourceDictionaryContentProvider)cachedThemeContent, themeAssemblyPath, (Func <ResourceDictionaryContentProvider, Func <DocumentNode, object> >)(i => new Func <DocumentNode, object>(((ThemeContentProvider.SystemThemeContentProvider)i).CreateInstance)), (Func <Uri, string, string>)((relativeUri, sourcePath) =>
                {
                    if (themeAssembly != null && relativeUri != (Uri)null)
                    {
                        string str1 = "pack://application:,,,/" + themeAssembly.Name + ";component/";
                        Uri uri1    = new Uri(str1);
                        Uri uri2    = KnownProjectBase.MakeDesignTimeUri(relativeUri, str1, sourcePath, themeAssembly.Name, (IEnumerable <IProject>)null);
                        if (uri2 != (Uri)null && uri2.IsAbsoluteUri)
                        {
                            Uri uri3 = uri1.MakeRelativeUri(uri2);
                            if (uri3 != (Uri)null)
                            {
                                string str2 = uri3.OriginalString.ToLowerInvariant();
                                if (resolvedUris.Contains(str2))
                                {
                                    return((string)null);
                                }
                                resolvedUris.Add(str2);
                                return(str2);
                            }
                        }
                    }
                    return((string)null);
                }), (Func <string, ResourceDictionaryContentProvider>)(resolvedUri =>
                {
                    if (themeAssembly != null && !string.IsNullOrEmpty(resolvedUri))
                    {
                        return((ResourceDictionaryContentProvider)this.GetCachedThemeContent(themeCache, manager, projectContext, DocumentReference.Create(Path.Combine(themeAssembly.Name, resolvedUri)), themeAssembly, resolvedUri, this.designerContext.TextBufferService));
                    }
                    return((ResourceDictionaryContentProvider)null);
                }), resourceKey, out auxillaryResources);
            }
            return(documentNode);
        }