Пример #1
0
            public override void Reload(IEnumerable <string> paths)
            {
                if (paths == null)
                {
                    throw new ArgumentNullException("paths");
                }

                StopMonitor(); // Make sure we have no further locks while reloading!

                HybridCollection <string> changed = new HybridCollection <string>(StringComparer.OrdinalIgnoreCase);

                changed.AddRange(paths);

                IProjectFileMapper mapper = _tracker.GetService <IProjectFileMapper>();

                if (!string.IsNullOrEmpty(mapper.SolutionFilename) && changed.Contains(mapper.SolutionFilename))
                {
                    // Ok; we are going to reload the solution itself
                    _tracker.SaveAllDocumentsExcept(changed); // Make sure everything that is dirty is saved

                    // let's remove all documents that are in the solution from the changed list
                    foreach (string file in mapper.GetAllFilesOfAllProjects())
                    {
                        changed.Remove(file);
                    }

                    // The solution was just removed; add it back
                    changed.Add(mapper.SolutionFilename);
                }

                for (int i = 0; i < changed.Count; i++)
                {
                    string          ch = changed[i];
                    SccDocumentData dd;
                    if (_tracker._docMap.TryGetValue(ch, out dd))
                    {
                        if (!dd.Reload(true))
                        {
                            string parentDocument = _tracker.GetParentDocument(dd);

                            if (string.IsNullOrEmpty(parentDocument))
                            {
                                parentDocument = mapper.SolutionFilename;
                            }

                            if (!string.IsNullOrEmpty(parentDocument) && !changed.Contains(parentDocument))
                            {
                                if (!_locked.Contains(parentDocument))
                                {
                                    // The parent is not on our changed or locked list.. so make sure it is saved
                                    _tracker.SaveDocument(parentDocument);
                                }

                                changed.Add(parentDocument);
                            }
                        }
                    }
                }
            }
Пример #2
0
            public SccDocumentLock(OpenDocumentTracker tracker, HybridCollection <string> locked, HybridCollection <string> ignoring, HybridCollection <string> readOnly)
            {
                ThreadHelper.ThrowIfNotOnUIThread();

                if (tracker == null)
                {
                    throw new ArgumentNullException("tracker");
                }
                else if (locked == null)
                {
                    throw new ArgumentNullException("locked");
                }
                else if (ignoring == null)
                {
                    throw new ArgumentNullException("ignoring");
                }
                else if (readOnly == null)
                {
                    throw new ArgumentNullException("readOnly");
                }

                _tracker      = tracker;
                _locked       = locked;
                _ignoring     = ignoring;
                _readonly     = readOnly;
                _fsIgnored    = new HybridCollection <string>(StringComparer.OrdinalIgnoreCase);
                _changedPaths = new HybridCollection <string>(StringComparer.OrdinalIgnoreCase);
                _monitor      = new Dictionary <uint, string>();
                _altMonitor   = new Dictionary <string, FileInfo>();

                _change = tracker.GetService <IVsFileChangeEx>(typeof(SVsFileChangeEx));

                foreach (string file in locked)
                {
                    // This files auto reload could not be suspended by calling Ignore on the document
                    // We must therefore stop posting messages to it by stopping it in the change monitor

                    // But to be able to tell if there are changes.. We keep some stats ourselves

                    if (!ignoring.Contains(file) &&
                        VSErr.Succeeded(_change.IgnoreFile(0, file, 1)))
                    {
                        _fsIgnored.Add(file);
                        FileInfo info = new FileInfo(file);
                        info.Refresh();
                        if (info.Exists)
                        {
                            GC.KeepAlive(info.LastWriteTime);
                            GC.KeepAlive(info.CreationTime);
                            GC.KeepAlive(info.Length);
                        }
                        _altMonitor.Add(file, info);
                    }
                }
            }
Пример #3
0
            public SccDocumentLock(OpenDocumentTracker tracker, HybridCollection<string> locked, HybridCollection<string> ignoring, HybridCollection<string> readOnly)
            {
                if (tracker == null)
                    throw new ArgumentNullException("tracker");
                else if (locked == null)
                    throw new ArgumentNullException("locked");
                else if (ignoring == null)
                    throw new ArgumentNullException("ignoring");
                else if (readOnly == null)
                    throw new ArgumentNullException("readOnly");

                _tracker = tracker;
                _locked = locked;
                _ignoring = ignoring;
                _readonly = readOnly;
                _fsIgnored = new HybridCollection<string>(StringComparer.OrdinalIgnoreCase);
                _changedPaths = new HybridCollection<string>(StringComparer.OrdinalIgnoreCase);
                _monitor = new Dictionary<uint, string>();
                _altMonitor = new Dictionary<string, FileInfo>();

                _change = tracker.GetService<IVsFileChangeEx>(typeof(SVsFileChangeEx));

                foreach (string file in locked)
                {
                    // This files auto reload could not be suspended by calling Ignore on the document
                    // We must therefore stop posting messages to it by stopping it in the change monitor

                    // But to be able to tell if there are changes.. We keep some stats ourselves

                    if (!ignoring.Contains(file) &&
                        ErrorHandler.Succeeded(_change.IgnoreFile(0, file, 1)))
                    {
                        _fsIgnored.Add(file);
                        FileInfo info = new FileInfo(file);
                        info.Refresh();
                        if (info.Exists)
                        {
                            GC.KeepAlive(info.LastWriteTime);
                            GC.KeepAlive(info.CreationTime);
                            GC.KeepAlive(info.Length);
                        }
                        _altMonitor.Add(file, info);
                    }
                }
            }