Exemplo n.º 1
0
        private IExportProviderFactory GetOrCreateFactory()
        {
            var key = new CacheKey(Assemblies, Parts, ExcludedPartTypes);

            lock (s_factoryCache)
            {
                if (s_factoryCache.TryGetValue(key, out var existing))
                {
                    return(existing);
                }
            }

            var newFactory = ExportProviderCache.CreateExportProviderFactory(GetCatalog(), IsRemote);

            lock (s_factoryCache)
            {
                if (s_factoryCache.TryGetValue(key, out var existing))
                {
                    return(existing);
                }

                s_factoryCache.Add(key, newFactory);
            }

            return(newFactory);
        }