private void RegisterAssemblies()
        {
            if (this.activeProject == null)
            {
                return;
            }
            List <AssemblyAssetProvider> list1;

            if (this.cachedProjectProviders.TryGetValue(this.activeProject, out list1))
            {
                foreach (AssetProvider provider in list1)
                {
                    this.AddProvider(provider);
                }
            }
            else
            {
                list1 = new List <AssemblyAssetProvider>();
                foreach (IAssembly assembly in (IEnumerable <IAssembly>) this.activeProject.AssemblyReferences)
                {
                    string name = assembly.Name;
                    if (!assembly.IsResolvedImplicitAssembly && string.Compare(name, "System", StringComparison.OrdinalIgnoreCase) != 0 && (string.Compare(name, "System.Core", StringComparison.OrdinalIgnoreCase) != 0 && string.Compare(name, "mscorlib", StringComparison.OrdinalIgnoreCase) != 0) && (string.Compare(name, "System.Data", StringComparison.OrdinalIgnoreCase) != 0 && string.Compare(name, "System.Xml", StringComparison.OrdinalIgnoreCase) != 0 && (string.Compare(name, "WindowsBase", StringComparison.OrdinalIgnoreCase) != 0 && string.Compare(name, "System.Xml.Linq", StringComparison.OrdinalIgnoreCase) != 0)) && (string.Compare(name, "System.Xaml", StringComparison.OrdinalIgnoreCase) != 0 && string.Compare(name, "System.Data.DataSetExtensions", StringComparison.OrdinalIgnoreCase) != 0 && string.Compare(name, "System.Activities", StringComparison.OrdinalIgnoreCase) != 0))
                    {
                        bool isMainAssembly = assembly.Equals((object)this.activeProject.ProjectAssembly);
                        AssemblyAssetProvider assemblyAssetProvider = new AssemblyAssetProvider(this.activeProject, assembly, isMainAssembly);
                        this.AddProvider((AssetProvider)assemblyAssetProvider);
                        list1.Add(assemblyAssetProvider);
                    }
                }
                this.cachedProjectProviders.Add(this.activeProject, list1);
            }
            Tuple <List <AssemblyAssetProvider>, AssemblyAssetAggregator.ProviderCache> tuple = this.BuildGlobalProviders();
            List <AssemblyAssetProvider> list2 = tuple.Item1;

            AssemblyAssetAggregator.ProviderCache providerCache = tuple.Item2;
            if (!AssemblyAssetAggregator.UseThreads || !EnumerableExtensions.CountIsMoreThan <AssemblyAssetProvider>((IEnumerable <AssemblyAssetProvider>)list2, 0))
            {
                return;
            }
            AssemblyAssetAggregator.ProviderWorker providerWorker = new AssemblyAssetAggregator.ProviderWorker(providerCache);
            providerWorker.DoWork             += new DoWorkEventHandler(this.OnWorkerDoWork);
            providerWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.Worker_RunWorkerCompleted);
            this.workers.Add(providerWorker);
            providerWorker.RunWorkerAsync((object)list2);
        }
        private void OnWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            AssemblyAssetAggregator.ProviderWorker providerWorker = sender as AssemblyAssetAggregator.ProviderWorker;
            providerWorker.DoWork -= new DoWorkEventHandler(this.OnWorkerDoWork);
            List <AssemblyAssetProvider> list = (List <AssemblyAssetProvider>)e.Argument;

            if (Enumerable.FirstOrDefault <AssemblyAssetProvider>((IEnumerable <AssemblyAssetProvider>)list) == null)
            {
                return;
            }
            AppDomain domain = AppDomain.CreateDomain("AssetToolDomain", (Evidence)null, new AppDomainSetup()
            {
                DisallowBindingRedirects = true
            });

            try
            {
                using (ProjectPathHelper.TemporaryDirectory temporaryDirectory = new ProjectPathHelper.TemporaryDirectory())
                {
                    using (List <AssemblyAssetProvider> .Enumerator enumerator = list.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            AssemblyAssetProvider provider = enumerator.Current;
                            if (providerWorker.CancellationPending)
                            {
                                break;
                            }
                            if (!provider.AsynchronizedInitialize(domain, temporaryDirectory.Path, (IBackgroundWorkerWrapper)providerWorker))
                            {
                                providerWorker.InvokeUIThread(DispatcherPriority.Background, (Action)(() => this.RemoveProvider((AssetProvider)provider)));
                            }
                        }
                    }
                }
            }
            finally
            {
                AppDomain.Unload(domain);
            }
        }
        private Tuple <List <AssemblyAssetProvider>, AssemblyAssetAggregator.ProviderCache> BuildGlobalProviders()
        {
            HashSet <string> hashSet1 = new HashSet <string>();

            foreach (IAssembly assembly in (IEnumerable <IAssembly>) this.activeProject.AssemblyReferences)
            {
                if (assembly.IsLoaded && !assembly.IsResolvedImplicitAssembly)
                {
                    hashSet1.Add(assembly.Name);
                }
            }
            AssemblyAssetAggregator.ProviderCache providerCache = (AssemblyAssetAggregator.ProviderCache) this.activeProject.Platform.Metadata.GetPlatformCache(DesignSurfacePlatformCaches.AssemblyAssetProviders);
            List <AssemblyAssetProvider>          list          = new List <AssemblyAssetProvider>();

            if (providerCache != null)
            {
                foreach (AssemblyAssetProvider assemblyAssetProvider in (List <AssemblyAssetProvider>)providerCache)
                {
                    if (!hashSet1.Contains(assemblyAssetProvider.AssemblyName))
                    {
                        this.AddProvider((AssetProvider)assemblyAssetProvider);
                        EnumerableExtensions.ForEach <TypeAsset>(Enumerable.OfType <TypeAsset>((IEnumerable)assemblyAssetProvider.Assets), (Action <TypeAsset>)(asset => asset.OnProjectChanged()));
                    }
                }
            }
            else
            {
                providerCache            = new AssemblyAssetAggregator.ProviderCache();
                providerCache.Disposing += new EventHandler(this.ProviderCache_Disposing);
                foreach (string path in new HashSet <string>(BlendSdkHelper.GetExtensionDirectories(this.activeProject.TargetFramework)))
                {
                    string[]         files    = Directory.GetFiles(path, "*.dll");
                    HashSet <string> hashSet2 = new HashSet <string>();
                    foreach (string filename in files)
                    {
                        foreach (string str in AssemblyAssetAggregator.GetDesignFileNames(filename, true))
                        {
                            hashSet2.Add(str);
                        }
                    }
                    foreach (string filename in files)
                    {
                        if (!hashSet2.Contains(filename.ToUpperInvariant()))
                        {
                            IAssemblyLoggingService assemblyLoggingService = (IAssemblyLoggingService)null;
                            if (this.designerContext.Services != null)
                            {
                                assemblyLoggingService = this.designerContext.Services.GetService <IAssemblyLoggingService>();
                            }
                            AssemblyAssetProvider assemblyAssetProvider = new AssemblyAssetProvider(this.activeProject, assemblyLoggingService, filename);
                            providerCache.Add(assemblyAssetProvider);
                            list.Add(assemblyAssetProvider);
                            this.AddProvider((AssetProvider)assemblyAssetProvider);
                        }
                    }
                }
                if (!AssetLibrary.DisableAsyncUpdateCache)
                {
                    this.activeProject.Platform.Metadata.SetPlatformCache(DesignSurfacePlatformCaches.AssemblyAssetProviders, (object)providerCache);
                }
            }
            return(new Tuple <List <AssemblyAssetProvider>, AssemblyAssetAggregator.ProviderCache>(list, providerCache));
        }