예제 #1
0
        private void Initialize(bool watchFiles)
        {
            _loader = new AssemblyLoader();
            string rootDirectory = ResolveRootDirectory(_projectDir);

#if DESKTOP // CORECLR_TODO: FileSystemWatcher
            if (watchFiles)
            {
                _watcher            = new FileWatcher(rootDirectory);
                _watcher.OnChanged += OnWatcherChanged;
            }
            else
#endif
            {
                _watcher = NoopWatcher.Instance;
            }

            var globalAssemblyCache = new DefaultGlobalAssemblyCache();

            var cachedLoader = new CachedCompilationLoader(rootDirectory);
            _loader.Add(cachedLoader);
            var resolver         = new FrameworkReferenceResolver(globalAssemblyCache);
            var resourceProvider = new ResxResourceProvider();
            var roslynLoader     = new RoslynAssemblyLoader(rootDirectory, _watcher, resolver, globalAssemblyCache, _loader, resourceProvider);
            _loader.Add(roslynLoader);
#if DESKTOP // CORECLR_TODO: Process
            _loader.Add(new MSBuildProjectAssemblyLoader(rootDirectory, _watcher));
#endif
            _loader.Add(new NuGetAssemblyLoader(_projectDir));

            _hostServices[HostServices.ResolveAssemblyReference] = new Func <string, object>(name =>
            {
                var an = new AssemblyName(name);

                return(_loader.ResolveReference(an.Name));
            });
        }
예제 #2
0
        private static AssemblyLoader CreateLoader(string projectDir)
        {
            var globalAssemblyCache = new DefaultGlobalAssemblyCache();

            var loader = new AssemblyLoader();
            string rootDirectory = ResolveRootDirectory(projectDir);
            var resolver = new FrameworkReferenceResolver(globalAssemblyCache);
            var resourceProvider = new ResxResourceProvider();
            var roslynLoader = new RoslynAssemblyLoader(rootDirectory, NoopWatcher.Instance, resolver, globalAssemblyCache, loader, resourceProvider);
            loader.Add(roslynLoader);
            #if DESKTOP
            loader.Add(new MSBuildProjectAssemblyLoader(rootDirectory, NoopWatcher.Instance));
            #endif
            loader.Add(new NuGetAssemblyLoader(projectDir));

            return loader;
        }