Ejemplo n.º 1
0
        public FileWatchedPortableExecutableReferenceFactory(
            Lazy <VisualStudioWorkspace> visualStudioWorkspace,
            FileChangeWatcherProvider fileChangeWatcherProvider)
        {
            _visualStudioWorkspace = visualStudioWorkspace;

            // TODO: set this to watch the NuGet directory or the reference assemblies directory; since those change rarely and most references
            // will come from them, we can avoid creating a bunch of explicit file watchers.
            _fileReferenceChangeContext              = fileChangeWatcherProvider.Watcher.CreateContext();
            _fileReferenceChangeContext.FileChanged += FileReferenceChangeContext_FileChanged;
        }
        public FileWatchedPortableExecutableReferenceFactory(
            Lazy <VisualStudioWorkspace> visualStudioWorkspace,
            FileChangeWatcherProvider fileChangeWatcherProvider)
        {
            _visualStudioWorkspace = visualStudioWorkspace;

            // We will do a single directory watch on the Reference Assemblies folder to avoid having to create separate file
            // watches on individual .dlls that effectively never change.
            var referenceAssembliesPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "Reference Assemblies", "Microsoft", "Framework");
            var referenceAssemblies     = new FileChangeWatcher.WatchedDirectory(referenceAssembliesPath, ".dll");

            // TODO: set this to watch the NuGet directory as well; there's some concern that watching the entire directory
            // might make restores take longer because we'll be watching changes that may not impact your project.

            _fileReferenceChangeContext              = fileChangeWatcherProvider.Watcher.CreateContext(referenceAssemblies);
            _fileReferenceChangeContext.FileChanged += FileReferenceChangeContext_FileChanged;
        }