private void EnsureContexts() { ThreadHelper.ThrowIfNotOnUIThread(); if (_otherSccProviderContexts == null) { List <SccData> sccs = new List <SccData>(); ILocalRegistry2 lr = GetService <ILocalRegistry2>(typeof(SLocalRegistry)); string root; List <string> names = new List <string>(); if (VSErr.Succeeded(lr.GetLocalRegistryRoot(out root))) { RegistryKey baseKey = Registry.LocalMachine; // TODO: Find some way to use the VS2008 RANU api if (root.EndsWith("\\UserSettings")) { root = root.Substring(0, root.Length - 13) + "\\Configuration"; baseKey = Registry.CurrentUser; } using (RegistryKey rk = baseKey.OpenSubKey(root + "\\SourceControlProviders", RegistryKeyPermissionCheck.ReadSubTree)) { if (rk != null) { string myId = AnkhId.SccProviderGuid.ToString("B"); foreach (string name in rk.GetSubKeyNames()) { if (name.Length == 38 && !myId.Equals(name, StringComparison.OrdinalIgnoreCase)) { try { using (RegistryKey rks = rk.OpenSubKey(name, RegistryKeyPermissionCheck.ReadSubTree)) { string service = rks.GetValue("Service") as string; if (!string.IsNullOrEmpty(service)) { Guid sccGuid = new Guid(name); CmdStateCacheItem cache = GetCache(new Guid(name)); sccs.Add(new SccData(cache, service)); } } } catch { } } } } } } _otherSccProviderContexts = sccs.ToArray(); } }
public SccData(CmdStateCacheItem cache, string service) { if (cache == null) { throw new ArgumentNullException("cache"); } else if (service == null) { throw new ArgumentNullException("service"); } _cache = cache; _service = new Guid(service).ToString(); }
private CmdStateCacheItem GetCache(Guid cmdContextId) { uint cookie; if (!VSErr.Succeeded(Monitor.GetCmdUIContextCookie(ref cmdContextId, out cookie))) { return(new CmdStateCacheItem(Monitor, 0)); } CmdStateCacheItem item; if (!_cookieMap.TryGetValue(cookie, out item)) { _cookieMap[cookie] = item = new CmdStateCacheItem(Monitor, cookie); } return(item); }
public SccData(CmdStateCacheItem cache, string service) { if (cache == null) throw new ArgumentNullException("cache"); else if (service == null) throw new ArgumentNullException("service"); _cache = cache; _service = new Guid(service).ToString(); }
private CmdStateCacheItem GetCache(Guid cmdContextId) { uint cookie; if (!ErrorHandler.Succeeded(Monitor.GetCmdUIContextCookie(ref cmdContextId, out cookie))) return new CmdStateCacheItem(Monitor, 0); CmdStateCacheItem item; if (!_cookieMap.TryGetValue(cookie, out item)) { _cookieMap[cookie] = item = new CmdStateCacheItem(Monitor, cookie); } return item; }