Exemplo n.º 1
0
            public ProjectListFilter(IAnkhServiceProvider context, IEnumerable <SccProject> projects)
            {
                if (context == null)
                {
                    throw new ArgumentNullException("context");
                }
                if (projects == null)
                {
                    throw new ArgumentNullException("projects");
                }

                _mapper = context.GetService <IProjectFileMapper>();
                List <SccProject> projectList = new List <SccProject>(projects);

                files.AddRange(_mapper.GetAllFilesOf(projectList));

                foreach (SccProject p in projectList)
                {
                    ISccProjectInfo pi = _mapper.GetProjectInfo(p);

                    if (pi == null)
                    {
                        continue; // Ignore solution and non scc projects
                    }
                    string dir = pi.ProjectDirectory;

                    if (!string.IsNullOrEmpty(dir) && !folders.Contains(dir))
                    {
                        folders.Add(dir);
                    }
                }
            }
Exemplo n.º 2
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);
                            }
                        }
                    }
                }
            }
Exemplo n.º 3
0
        IEnumerator <KeyValuePair <string, string> > IEnumerable <KeyValuePair <string, string> > .GetEnumerator()
        {
            using (RegistryKey key = OpenFifoKey(true))
            {
                int nSize;
                int nPos;

                if (!RegistryUtils.TryGetIntValue(key, "_size", out nSize) || nSize < 1)
                {
                    nSize = _defaultSize;
                }

                // This gives a very tiny race condition if used at the same time in
                // two VS instances.
                // We ignore this as it is just UI helper code and a user can't edit
                //  two windows at the same time
                if (!RegistryUtils.TryGetIntValue(key, "_pos", out nPos) || (nPos < 0) || (nPos >= nSize))
                {
                    nPos = 0;
                }

                HybridCollection <string> hs = new HybridCollection <string>();
                hs.AddRange(key.GetValueNames());

                for (int i = 0; i < nSize; i++)
                {
                    int n = nPos - i;
                    while (n < 0)
                    {
                        n += nSize;
                    }

                    string s = "#" + n.ToString(CultureInfo.InvariantCulture);

                    if (hs.Contains(s))
                    {
                        string v = key.GetValue(s) as string;

                        if (v != null && (_allowWhiteSpace || !string.IsNullOrEmpty(v)))
                        {
                            yield return(new KeyValuePair <string, string>(s, v));
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        IDictionary <string, int> GetNumberValues(string regKey, string subKey)
        {
            if (string.IsNullOrEmpty(regKey))
            {
                throw new ArgumentNullException("regKey");
            }
            if (string.IsNullOrEmpty(subKey))
            {
                throw new ArgumentNullException("subKey");
            }
            IDictionary <string, int> values;

            lock (_lock)
            {
                subKey = regKey + "\\" + subKey;
                using (RegistryKey reg = OpenHKCUKey(subKey))
                {
                    if (reg == null)
                    {
                        return(null);
                    }
                    HybridCollection <string> hs = new HybridCollection <string>();
                    hs.AddRange(reg.GetValueNames());

                    values = new Dictionary <string, int>(hs.Count);

                    foreach (string item in hs)
                    {
                        int width;
                        if (RegistryUtils.TryGetIntValue(reg, item, out width) && width > 0)
                        {
                            values.Add(item, width);
                        }
                    }
                }
            }
            return(values);
        }
Exemplo n.º 5
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, false))
                        {
                            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);
                            }
                        }
                    }
                }
            }
Exemplo n.º 6
0
        IDictionary<string, int> GetNumberValues(string regKey, string subKey)
        {
            if (string.IsNullOrEmpty(regKey))
                throw new ArgumentNullException("regKey");
            if (string.IsNullOrEmpty(subKey))
                throw new ArgumentNullException("subKey");
            IDictionary<string, int> values;
            lock (_lock)
            {
                subKey = regKey + "\\" + subKey;
                using (RegistryKey reg = OpenHKCUKey(subKey))
                {
                    if (reg == null)
                        return null;
                    HybridCollection<string> hs = new HybridCollection<string>();
                    hs.AddRange(reg.GetValueNames());

                    values = new Dictionary<string, int>(hs.Count);

                    foreach (string item in hs)
                    {
                        int width;
                        if (RegistryUtils.TryGetIntValue(reg, item, out width) && width > 0)
                            values.Add(item, width);
                    }
                }
            }
            return values;
        }