示例#1
0
            public void Dispose()
            {
                if (_cookie != 0)
                {
                    uint ck = _cookie;
                    _cookie = 0;

                    IVsFileChangeEx fx = GetService <IVsFileChangeEx>(typeof(SVsFileChangeEx));

                    if (fx != null)
                    {
                        if (!_monitorDir)
                        {
                            fx.UnadviseFileChange(ck);
                        }
                        else
                        {
                            fx.UnadviseDirChange(ck);
                        }
                    }
                }

                if (_odt != null)
                {
                    _odt.IgnoreChanges(_toMonitor, false);
                    _odt = null;
                }
            }
        internal void OpenTracker()
        {
            Debug.WriteLine("==== Open Tracker");
            trackers.Clear();

            var solutionFileName = GetSolutionFileName();

            if (!string.IsNullOrEmpty(solutionFileName))
            {
                monitorFolder = Path.GetDirectoryName(solutionFileName);

                GetLoadedControllableProjects().ForEach(h => AddProject(h as IVsHierarchy));

                if (monitorFolder != lastMinotorFolder)
                {
                    RemoveFolderMonitor();

                    IVsFileChangeEx fileChangeService = _sccProvider.GetService(typeof(SVsFileChangeEx)) as IVsFileChangeEx;
                    if (VSConstants.VSCOOKIE_NIL != _vsIVsFileChangeEventsCookie)
                    {
                        fileChangeService.UnadviseDirChange(_vsIVsFileChangeEventsCookie);
                    }
                    fileChangeService.AdviseDirChange(monitorFolder, 1, this, out _vsIVsFileChangeEventsCookie);
                    lastMinotorFolder = monitorFolder;

                    Debug.WriteLine("==== Monitoring: " + monitorFolder + " " + _vsIVsFileChangeEventsCookie);
                }
            }
        }
示例#3
0
        private void Unwatch(uint cookie)
        {
            if (_changeService == null || cookie == 0)
            {
                return;
            }

            ErrorHandler.ThrowOnFailure(_changeService.UnadviseDirChange(cookie));
        }
 private void RemoveFolderMonitor()
 {
     if (VSConstants.VSCOOKIE_NIL != _vsIVsFileChangeEventsCookie)
     {
         IVsFileChangeEx fileChangeService = _sccProvider.GetService(typeof(SVsFileChangeEx)) as IVsFileChangeEx;
         fileChangeService.UnadviseDirChange(_vsIVsFileChangeEventsCookie);
         Debug.WriteLine("==== Stop Monitoring: " + _vsIVsFileChangeEventsCookie.ToString());
         _vsIVsFileChangeEventsCookie = VSConstants.VSCOOKIE_NIL;
         lastMinotorFolder            = "";
     }
 }