Пример #1
0
        static CompositionManager.Caching GetCaching(CompositionManager.ICachingFaultInjector faultInjector = null, Action <string> onCacheFileRequested = null, [CallerMemberName] string testName = null)
        {
            var assemblies = CompositionManager.ReadAssembliesFromAddins();
            var caching    = new CompositionManager.Caching(assemblies, file => {
                onCacheFileRequested?.Invoke(file);

                var tmpDir = Path.Combine(Util.TmpDir, "mef", testName);
                if (Directory.Exists(tmpDir))
                {
                    Directory.Delete(tmpDir, true);
                }
                Directory.CreateDirectory(tmpDir);
                return(Path.Combine(tmpDir, file));
            }, faultInjector);

            return(caching);
        }
        public async Task ValidateRuntimeCompositionIsValid()
        {
            var mefAssemblies = CompositionManager.ReadAssembliesFromAddins();
            var caching       = new CompositionManager.Caching(mefAssemblies, file => {
                var tmpDir = Path.Combine(Util.TmpDir, "mef", nameof(ValidateRuntimeCompositionIsValid));
                if (Directory.Exists(tmpDir))
                {
                    Directory.Delete(tmpDir, true);
                }
                Directory.CreateDirectory(tmpDir);
                return(Path.Combine(tmpDir, file));
            }, exceptionHandler: new ThrowingHandler());

            var(composition, catalog) = await CompositionManager.CreateRuntimeCompositionFromDiscovery(caching);

            var cacheManager = new CachedComposition();

            await caching.Write(composition, catalog, cacheManager);
        }