System.Data.SQLite
Check-in [7ff0314780]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Refactor installer registry key helper methods into their own class and keep track of basic usage stats for reporting at the end.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7ff03147809c88ae73b5289eefd6d09268ed93c5
User & Date: mistachkin 2011-08-09 22:24:59
Context
2011-08-10
02:49
Prevent inlining of tracing methods that deal with stack frame introspection (i.e. fix method names reported in the log file). check-in: 3ad43e2de3 user: mistachkin tags: trunk
2011-08-09
22:24
Refactor installer registry key helper methods into their own class and keep track of basic usage stats for reporting at the end. check-in: 7ff0314780 user: mistachkin tags: trunk
20:52
Fix method names in trace messages and require the -confirm command line option prior to making any changes to the system. check-in: 793e9b039d user: mistachkin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tools/install/Installer.cs.

   744    744               }
   745    745               #endregion
   746    746           }
   747    747           #endregion
   748    748   
   749    749           ///////////////////////////////////////////////////////////////////////
   750    750   
          751  +        #region RegistryHelper Class
          752  +        private static class RegistryHelper
          753  +        {
          754  +            #region Public Static Properties
          755  +            private static int subKeysCreated;
          756  +            public static int SubKeysCreated
          757  +            {
          758  +                get { return subKeysCreated; }
          759  +            }
          760  +
          761  +            ///////////////////////////////////////////////////////////////////
          762  +
          763  +            private static int subKeysDeleted;
          764  +            public static int SubKeysDeleted
          765  +            {
          766  +                get { return subKeysDeleted; }
          767  +            }
          768  +
          769  +            ///////////////////////////////////////////////////////////////////
          770  +
          771  +            private static int keyValuesSet;
          772  +            public static int KeyValuesSet
          773  +            {
          774  +                get { return keyValuesSet; }
          775  +            }
          776  +
          777  +            ///////////////////////////////////////////////////////////////////
          778  +
          779  +            private static int keyValuesDeleted;
          780  +            public static int KeyValuesDeleted
          781  +            {
          782  +                get { return keyValuesDeleted; }
          783  +            }
          784  +            #endregion
          785  +
          786  +            ///////////////////////////////////////////////////////////////////
          787  +
          788  +            #region Public Static Methods
          789  +            public static RegistryKey GetRootKeyByName(
          790  +                string keyName
          791  +                )
          792  +            {
          793  +                if (String.IsNullOrEmpty(keyName))
          794  +                    return null;
          795  +
          796  +                switch (keyName.ToUpperInvariant())
          797  +                {
          798  +                    case "HKCR":
          799  +                    case "HKEY_CLASSES_ROOT":
          800  +                        return Registry.ClassesRoot;
          801  +                    case "HKCC":
          802  +                    case "HKEY_CURRENT_CONFIG":
          803  +                        return Registry.CurrentConfig;
          804  +                    case "HKCU":
          805  +                    case "HKEY_CURRENT_USER":
          806  +                        return Registry.CurrentUser;
          807  +                    case "HKDD":
          808  +                    case "HKEY_DYN_DATA":
          809  +                        return Registry.DynData;
          810  +                    case "HKLM":
          811  +                    case "HKEY_LOCAL_MACHINE":
          812  +                        return Registry.LocalMachine;
          813  +                    case "HKPD":
          814  +                    case "HKEY_PERFORMANCE_DATA":
          815  +                        return Registry.PerformanceData;
          816  +                    case "HKU":
          817  +                    case "HKEY_USERS":
          818  +                        return Registry.Users;
          819  +                }
          820  +
          821  +                return null;
          822  +            }
          823  +
          824  +            ///////////////////////////////////////////////////////////////////
          825  +
          826  +            public static MockRegistryKey OpenSubKey(
          827  +                MockRegistryKey rootKey,
          828  +                string subKeyName,
          829  +                bool writable,
          830  +                bool whatIf,
          831  +                bool verbose
          832  +                )
          833  +            {
          834  +                if (rootKey == null)
          835  +                    return null;
          836  +
          837  +                if (verbose)
          838  +                    TraceOps.Trace(traceCallback, String.Format(
          839  +                        "rootKey = {0}, subKeyName = {1}, writable = {2}",
          840  +                        ForDisplay(rootKey), ForDisplay(subKeyName), writable),
          841  +                        traceCategory);
          842  +
          843  +                //
          844  +                // HACK: Always forbid writable access when operating in
          845  +                //       'what-if' mode.
          846  +                //
          847  +                MockRegistryKey key = rootKey.OpenSubKey(
          848  +                    subKeyName, whatIf ? false : writable);
          849  +
          850  +                return (key != null) ?
          851  +                    new MockRegistryKey(key, whatIf) : null;
          852  +            }
          853  +
          854  +            ///////////////////////////////////////////////////////////////////
          855  +
          856  +            public static MockRegistryKey CreateSubKey(
          857  +                MockRegistryKey rootKey,
          858  +                string subKeyName,
          859  +                bool whatIf,
          860  +                bool verbose
          861  +                )
          862  +            {
          863  +                if (rootKey == null)
          864  +                    return null;
          865  +
          866  +                if (verbose)
          867  +                    TraceOps.Trace(traceCallback, String.Format(
          868  +                        "rootKey = {0}, subKeyName = {1}", ForDisplay(rootKey),
          869  +                        ForDisplay(subKeyName)), traceCategory);
          870  +
          871  +                try
          872  +                {
          873  +                    //
          874  +                    // HACK: Always open a key, rather than creating one when
          875  +                    //       operating in 'what-if' mode.
          876  +                    //
          877  +                    if (whatIf)
          878  +                    {
          879  +                        //
          880  +                        // HACK: Attempt to open the specified sub-key.  If
          881  +                        //       this fails, we will simply return the root key
          882  +                        //       itself since no writes are allowed in
          883  +                        //       'what-if' mode anyhow.
          884  +                        //
          885  +                        MockRegistryKey key = rootKey.OpenSubKey(subKeyName);
          886  +
          887  +                        return (key != null) ?
          888  +                            key : new MockRegistryKey(rootKey, subKeyName);
          889  +                    }
          890  +                    else
          891  +                    {
          892  +                        return new MockRegistryKey(
          893  +                            rootKey.CreateSubKey(subKeyName), false);
          894  +                    }
          895  +                }
          896  +                finally
          897  +                {
          898  +                    subKeysCreated++;
          899  +                }
          900  +            }
          901  +
          902  +            ///////////////////////////////////////////////////////////////////
          903  +
          904  +            public static void DeleteSubKey(
          905  +                MockRegistryKey rootKey,
          906  +                string subKeyName,
          907  +                bool whatIf,
          908  +                bool verbose
          909  +                )
          910  +            {
          911  +                if (rootKey == null)
          912  +                    return;
          913  +
          914  +                if (verbose)
          915  +                    TraceOps.Trace(traceCallback, String.Format(
          916  +                        "rootKey = {0}, subKeyName = {1}", ForDisplay(rootKey),
          917  +                        ForDisplay(subKeyName)), traceCategory);
          918  +
          919  +                if (!whatIf)
          920  +                    rootKey.DeleteSubKey(subKeyName);
          921  +
          922  +                subKeysDeleted++;
          923  +            }
          924  +
          925  +            ///////////////////////////////////////////////////////////////////
          926  +
          927  +            public static void DeleteSubKeyTree(
          928  +                MockRegistryKey rootKey,
          929  +                string subKeyName,
          930  +                bool whatIf,
          931  +                bool verbose
          932  +                )
          933  +            {
          934  +                if (rootKey == null)
          935  +                    return;
          936  +
          937  +                if (verbose)
          938  +                    TraceOps.Trace(traceCallback, String.Format(
          939  +                        "rootKey = {0}, subKeyName = {1}", ForDisplay(rootKey),
          940  +                        ForDisplay(subKeyName)), traceCategory);
          941  +
          942  +                if (!whatIf)
          943  +                    rootKey.DeleteSubKeyTree(subKeyName);
          944  +
          945  +                subKeysDeleted++;
          946  +            }
          947  +
          948  +            ///////////////////////////////////////////////////////////////////
          949  +
          950  +            public static string[] GetSubKeyNames(
          951  +                MockRegistryKey key,
          952  +                bool whatIf,
          953  +                bool verbose
          954  +                )
          955  +            {
          956  +                if (key == null)
          957  +                    return null;
          958  +
          959  +                if (verbose)
          960  +                    TraceOps.Trace(traceCallback, String.Format(
          961  +                        "key = {0}", ForDisplay(key)), traceCategory);
          962  +
          963  +                return key.GetSubKeyNames();
          964  +            }
          965  +
          966  +            ///////////////////////////////////////////////////////////////////
          967  +
          968  +            public static object GetValue(
          969  +                MockRegistryKey key,
          970  +                string name,
          971  +                object defaultValue,
          972  +                bool whatIf,
          973  +                bool verbose
          974  +                )
          975  +            {
          976  +                if (key == null)
          977  +                    return null;
          978  +
          979  +                if (verbose)
          980  +                    TraceOps.Trace(traceCallback, String.Format(
          981  +                        "key = {0}, name = {1}, defaultValue = {2}",
          982  +                        ForDisplay(key), ForDisplay(name),
          983  +                        ForDisplay(defaultValue)), traceCategory);
          984  +
          985  +                return key.GetValue(name, defaultValue);
          986  +            }
          987  +
          988  +            ///////////////////////////////////////////////////////////////////
          989  +
          990  +            public static void SetValue(
          991  +                MockRegistryKey key,
          992  +                string name,
          993  +                object value,
          994  +                bool whatIf,
          995  +                bool verbose
          996  +                )
          997  +            {
          998  +                if (key == null)
          999  +                    return;
         1000  +
         1001  +                if (verbose)
         1002  +                    TraceOps.Trace(traceCallback, String.Format(
         1003  +                        "key = {0}, name = {1}, value = {2}", ForDisplay(key),
         1004  +                        ForDisplay(name), ForDisplay(value)), traceCategory);
         1005  +
         1006  +                if (!whatIf)
         1007  +                    key.SetValue(name, value);
         1008  +
         1009  +                keyValuesSet++;
         1010  +            }
         1011  +
         1012  +            ///////////////////////////////////////////////////////////////////
         1013  +
         1014  +            public static void DeleteValue(
         1015  +                MockRegistryKey key,
         1016  +                string name,
         1017  +                bool whatIf,
         1018  +                bool verbose
         1019  +                )
         1020  +            {
         1021  +                if (key == null)
         1022  +                    return;
         1023  +
         1024  +                if (verbose)
         1025  +                    TraceOps.Trace(traceCallback, String.Format(
         1026  +                        "key = {0}, name = {1}", ForDisplay(key),
         1027  +                        ForDisplay(name)), traceCategory);
         1028  +
         1029  +                if (!whatIf)
         1030  +                    key.DeleteValue(name);
         1031  +
         1032  +                keyValuesDeleted++;
         1033  +            }
         1034  +            #endregion
         1035  +        }
         1036  +        #endregion
         1037  +
         1038  +        ///////////////////////////////////////////////////////////////////////
         1039  +
   751   1040           #region StringList Class
   752   1041           private sealed class StringList : List<string>
   753   1042           {
   754   1043               public StringList()
   755   1044                   : base()
   756   1045               {
   757   1046                   // do nothing.
................................................................................
   954   1243           private static string GetFrameworkDirectory(
   955   1244               RegistryKey rootKey,
   956   1245               Version frameworkVersion,
   957   1246               bool whatIf,
   958   1247               bool verbose
   959   1248               )
   960   1249           {
   961         -            using (MockRegistryKey key = OpenSubKey(
         1250  +            using (MockRegistryKey key = RegistryHelper.OpenSubKey(
   962   1251                       rootKey, FrameworkKeyName, false, whatIf, verbose))
   963   1252               {
   964   1253                   if (key == null)
   965   1254                       return null;
   966   1255   
   967         -                object value = GetValue(
         1256  +                object value = RegistryHelper.GetValue(
   968   1257                       key, "InstallRoot", null, whatIf, verbose);
   969   1258   
   970   1259                   if (!(value is string))
   971   1260                       return null;
   972   1261   
   973   1262                   return Path.Combine(
   974   1263                       (string)value, String.Format("v{0}", frameworkVersion));
................................................................................
  1002   1291                   false,
  1003   1292                   true,
  1004   1293                   true
  1005   1294               };
  1006   1295   
  1007   1296               for (int index = 0; index < keyNames.Length; index++)
  1008   1297               {
  1009         -                using (MockRegistryKey key = OpenSubKey(
         1298  +                using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  1010   1299                           rootKey, keyNames[index], false, whatIf, verbose))
  1011   1300                   {
  1012   1301                       if (key == null)
  1013   1302                           continue;
  1014   1303   
  1015   1304                       if (useSubKeys[index])
  1016   1305                       {
  1017         -                        foreach (string subKeyName in GetSubKeyNames(
         1306  +                        foreach (string subKeyName in RegistryHelper.GetSubKeyNames(
  1018   1307                                   key, whatIf, verbose))
  1019   1308                           {
  1020         -                            using (MockRegistryKey subKey = OpenSubKey(
         1309  +                            using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  1021   1310                                       key, subKeyName, false, whatIf, verbose))
  1022   1311                               {
  1023   1312                                   if (subKey == null)
  1024   1313                                       continue;
  1025   1314   
  1026         -                                object value = GetValue(
         1315  +                                object value = RegistryHelper.GetValue(
  1027   1316                                       subKey, valueNames[index], null, whatIf,
  1028   1317                                       verbose);
  1029   1318   
  1030   1319                                   if (!(value is string))
  1031   1320                                       continue;
  1032   1321   
  1033   1322                                   string path = (string)value;
................................................................................
  1051   1340                                   if (File.Exists(path))
  1052   1341                                       results.Add(subKey.Name, path);
  1053   1342                               }
  1054   1343                           }
  1055   1344                       }
  1056   1345                       else
  1057   1346                       {
  1058         -                        object value = GetValue(
         1347  +                        object value = RegistryHelper.GetValue(
  1059   1348                               key, valueNames[index], null, whatIf, verbose);
  1060   1349   
  1061   1350                           if (!(value is string))
  1062   1351                               continue;
  1063   1352   
  1064   1353                           string path = (string)value;
  1065   1354   
................................................................................
  1174   1463               string format = !String.IsNullOrEmpty(platformName) ?
  1175   1464                   "Software\\Microsoft\\{0}\\v{1}\\{2}" :
  1176   1465                   "Software\\Microsoft\\{0}\\v{1}";
  1177   1466   
  1178   1467               string keyName = String.Format(
  1179   1468                   format, frameworkName, frameworkVersion, platformName);
  1180   1469   
  1181         -            using (MockRegistryKey key = OpenSubKey(
         1470  +            using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  1182   1471                       rootKey, keyName, false, whatIf, verbose))
  1183   1472               {
  1184   1473                   if (key == null)
  1185   1474                       return false;
  1186   1475   
  1187   1476                   if (platformName != null) // NOTE: Skip non-desktop frameworks.
  1188   1477                       return true;
................................................................................
  1341   1630                               ".NET Framework v{0} file \"{1}\" does not exist, " +
  1342   1631                               "skipping...", frameworkVersion, fileName),
  1343   1632                               traceCategory);
  1344   1633   
  1345   1634                           continue;
  1346   1635                       }
  1347   1636   
         1637  +                    bool localSaved = false;
         1638  +
  1348   1639                       if (!callback(
  1349   1640                               fileName, invariant, name, description, typeName,
  1350   1641                               assemblyName, clientData, whatIf, verbose,
  1351         -                            ref saved, ref error))
         1642  +                            ref localSaved, ref error))
  1352   1643                       {
  1353   1644                           return false;
  1354   1645                       }
         1646  +                    else
         1647  +                    {
         1648  +                        if (localSaved && !saved)
         1649  +                            saved = true;
         1650  +
         1651  +                        TraceOps.Trace(traceCallback, String.Format(
         1652  +                            "localSaved = {0}, saved = {1}", localSaved,
         1653  +                            saved), traceCategory);
         1654  +                    }
  1355   1655                   }
  1356   1656               }
  1357   1657   
  1358   1658               return true;
  1359   1659           }
  1360   1660   
  1361   1661           ///////////////////////////////////////////////////////////////////////
................................................................................
  1520   1820               bool whatIf,
  1521   1821               bool verbose
  1522   1822               )
  1523   1823           {
  1524   1824               string format = "Software\\Microsoft\\VisualStudio\\{0}";
  1525   1825               string keyName = String.Format(format, vsVersion);
  1526   1826   
  1527         -            using (MockRegistryKey key = OpenSubKey(
         1827  +            using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  1528   1828                       rootKey, keyName, false, whatIf, verbose))
  1529   1829               {
  1530   1830                   if (key == null)
  1531   1831                       return false;
  1532   1832   
  1533         -                object value = GetValue(
         1833  +                object value = RegistryHelper.GetValue(
  1534   1834                       key, "InstallDir", null, whatIf, verbose);
  1535   1835   
  1536   1836                   if (!(value is string))
  1537   1837                       return false;
  1538   1838   
  1539   1839                   string directory = (string)value;
  1540   1840   
................................................................................
  1608   1908                   {
  1609   1909                       return false;
  1610   1910                   }
  1611   1911               }
  1612   1912   
  1613   1913               return true;
  1614   1914           }
  1615         -        #endregion
  1616         -
  1617         -        ///////////////////////////////////////////////////////////////////////
  1618         -
  1619         -        #region Generic Registry Handling
  1620         -        private static RegistryKey GetRootKeyByName(
  1621         -            string keyName
  1622         -            )
  1623         -        {
  1624         -            if (String.IsNullOrEmpty(keyName))
  1625         -                return null;
  1626         -
  1627         -            switch (keyName.ToUpperInvariant())
  1628         -            {
  1629         -                case "HKCR":
  1630         -                case "HKEY_CLASSES_ROOT":
  1631         -                    return Registry.ClassesRoot;
  1632         -                case "HKCC":
  1633         -                case "HKEY_CURRENT_CONFIG":
  1634         -                    return Registry.CurrentConfig;
  1635         -                case "HKCU":
  1636         -                case "HKEY_CURRENT_USER":
  1637         -                    return Registry.CurrentUser;
  1638         -                case "HKDD":
  1639         -                case "HKEY_DYN_DATA":
  1640         -                    return Registry.DynData;
  1641         -                case "HKLM":
  1642         -                case "HKEY_LOCAL_MACHINE":
  1643         -                    return Registry.LocalMachine;
  1644         -                case "HKPD":
  1645         -                case "HKEY_PERFORMANCE_DATA":
  1646         -                    return Registry.PerformanceData;
  1647         -                case "HKU":
  1648         -                case "HKEY_USERS":
  1649         -                    return Registry.Users;
  1650         -            }
  1651         -
  1652         -            return null;
  1653         -        }
  1654         -
  1655         -        ///////////////////////////////////////////////////////////////////////
  1656         -
  1657         -        private static MockRegistryKey OpenSubKey(
  1658         -            MockRegistryKey rootKey,
  1659         -            string subKeyName,
  1660         -            bool writable,
  1661         -            bool whatIf,
  1662         -            bool verbose
  1663         -            )
  1664         -        {
  1665         -            if (rootKey == null)
  1666         -                return null;
  1667         -
  1668         -            if (verbose)
  1669         -                TraceOps.Trace(traceCallback, String.Format(
  1670         -                    "rootKey = {0}, subKeyName = {1}, writable = {2}",
  1671         -                    ForDisplay(rootKey), ForDisplay(subKeyName), writable),
  1672         -                    traceCategory);
  1673         -
  1674         -            //
  1675         -            // HACK: Always forbid writable access when operating in 'what-if'
  1676         -            //       mode.
  1677         -            //
  1678         -            MockRegistryKey key = rootKey.OpenSubKey(
  1679         -                subKeyName, whatIf ? false : writable);
  1680         -
  1681         -            return (key != null) ?
  1682         -                new MockRegistryKey(key, whatIf) : null;
  1683         -        }
  1684         -
  1685         -        ///////////////////////////////////////////////////////////////////////
  1686         -
  1687         -        private static MockRegistryKey CreateSubKey(
  1688         -            MockRegistryKey rootKey,
  1689         -            string subKeyName,
  1690         -            bool whatIf,
  1691         -            bool verbose
  1692         -            )
  1693         -        {
  1694         -            if (rootKey == null)
  1695         -                return null;
  1696         -
  1697         -            if (verbose)
  1698         -                TraceOps.Trace(traceCallback, String.Format(
  1699         -                    "rootKey = {0}, subKeyName = {1}", ForDisplay(rootKey),
  1700         -                    ForDisplay(subKeyName)), traceCategory);
  1701         -
  1702         -            //
  1703         -            // HACK: Always open a key, rather than creating one when operating
  1704         -            //       in 'what-if' mode.
  1705         -            //
  1706         -            if (whatIf)
  1707         -            {
  1708         -                //
  1709         -                // HACK: Attempt to open the specified sub-key.  If this
  1710         -                //       fails, we will simply return the root key itself
  1711         -                //       since no writes are allowed in 'what-if' mode
  1712         -                //       anyhow.
  1713         -                //
  1714         -                MockRegistryKey key = rootKey.OpenSubKey(subKeyName);
  1715         -
  1716         -                return (key != null) ?
  1717         -                    key : new MockRegistryKey(rootKey, subKeyName);
  1718         -            }
  1719         -            else
  1720         -            {
  1721         -                return new MockRegistryKey(
  1722         -                    rootKey.CreateSubKey(subKeyName), false);
  1723         -            }
  1724         -        }
  1725         -
  1726         -        ///////////////////////////////////////////////////////////////////////
  1727         -
  1728         -        private static void DeleteSubKey(
  1729         -            MockRegistryKey rootKey,
  1730         -            string subKeyName,
  1731         -            bool whatIf,
  1732         -            bool verbose
  1733         -            )
  1734         -        {
  1735         -            if (rootKey == null)
  1736         -                return;
  1737         -
  1738         -            if (verbose)
  1739         -                TraceOps.Trace(traceCallback, String.Format(
  1740         -                    "rootKey = {0}, subKeyName = {1}", ForDisplay(rootKey),
  1741         -                    ForDisplay(subKeyName)), traceCategory);
  1742         -
  1743         -            if (!whatIf)
  1744         -                rootKey.DeleteSubKey(subKeyName);
  1745         -        }
  1746         -
  1747         -        ///////////////////////////////////////////////////////////////////////
  1748         -
  1749         -        private static void DeleteSubKeyTree(
  1750         -            MockRegistryKey rootKey,
  1751         -            string subKeyName,
  1752         -            bool whatIf,
  1753         -            bool verbose
  1754         -            )
  1755         -        {
  1756         -            if (rootKey == null)
  1757         -                return;
  1758         -
  1759         -            if (verbose)
  1760         -                TraceOps.Trace(traceCallback, String.Format(
  1761         -                    "rootKey = {0}, subKeyName = {1}", ForDisplay(rootKey),
  1762         -                    ForDisplay(subKeyName)), traceCategory);
  1763         -
  1764         -            if (!whatIf)
  1765         -                rootKey.DeleteSubKeyTree(subKeyName);
  1766         -        }
  1767         -
  1768         -        ///////////////////////////////////////////////////////////////////////
  1769         -
  1770         -        private static string[] GetSubKeyNames(
  1771         -            MockRegistryKey key,
  1772         -            bool whatIf,
  1773         -            bool verbose
  1774         -            )
  1775         -        {
  1776         -            if (key == null)
  1777         -                return null;
  1778         -
  1779         -            if (verbose)
  1780         -                TraceOps.Trace(traceCallback, String.Format(
  1781         -                    "key = {0}", ForDisplay(key)), traceCategory);
  1782         -
  1783         -            return key.GetSubKeyNames();
  1784         -        }
  1785         -
  1786         -        ///////////////////////////////////////////////////////////////////////
  1787         -
  1788         -        private static object GetValue(
  1789         -            MockRegistryKey key,
  1790         -            string name,
  1791         -            object defaultValue,
  1792         -            bool whatIf,
  1793         -            bool verbose
  1794         -            )
  1795         -        {
  1796         -            if (key == null)
  1797         -                return null;
  1798         -
  1799         -            if (verbose)
  1800         -                TraceOps.Trace(traceCallback, String.Format(
  1801         -                    "key = {0}, name = {1}, defaultValue = {2}",
  1802         -                    ForDisplay(key), ForDisplay(name),
  1803         -                    ForDisplay(defaultValue)), traceCategory);
  1804         -
  1805         -            return key.GetValue(name, defaultValue);
  1806         -        }
  1807         -
  1808         -        ///////////////////////////////////////////////////////////////////////
  1809         -
  1810         -        private static void SetValue(
  1811         -            MockRegistryKey key,
  1812         -            string name,
  1813         -            object value,
  1814         -            bool whatIf,
  1815         -            bool verbose
  1816         -            )
  1817         -        {
  1818         -            if (key == null)
  1819         -                return;
  1820         -
  1821         -            if (verbose)
  1822         -                TraceOps.Trace(traceCallback, String.Format(
  1823         -                    "key = {0}, name = {1}, value = {2}", ForDisplay(key),
  1824         -                    ForDisplay(name), ForDisplay(value)), traceCategory);
  1825         -
  1826         -            if (!whatIf)
  1827         -                key.SetValue(name, value);
  1828         -        }
  1829         -
  1830         -        ///////////////////////////////////////////////////////////////////////
  1831         -
  1832         -        private static void DeleteValue(
  1833         -            MockRegistryKey key,
  1834         -            string name,
  1835         -            bool whatIf,
  1836         -            bool verbose
  1837         -            )
  1838         -        {
  1839         -            if (key == null)
  1840         -                return;
  1841         -
  1842         -            if (verbose)
  1843         -                TraceOps.Trace(traceCallback, String.Format(
  1844         -                    "key = {0}, name = {1}", ForDisplay(key),
  1845         -                    ForDisplay(name)), traceCategory);
  1846         -
  1847         -            if (!whatIf)
  1848         -                key.DeleteValue(name);
  1849         -        }
  1850   1915           #endregion
  1851   1916   
  1852   1917           ///////////////////////////////////////////////////////////////////////
  1853   1918   
  1854   1919           #region Configuration File Handling
  1855   1920           private static bool AddDbProviderFactory(
  1856   1921               string fileName,
................................................................................
  2075   2140               bool verbose,
  2076   2141               ref string error
  2077   2142               )
  2078   2143           {
  2079   2144               string keyName = GetAssemblyFoldersKeyName(
  2080   2145                   frameworkName, frameworkVersion, platformName);
  2081   2146   
  2082         -            using (MockRegistryKey key = OpenSubKey(
         2147  +            using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  2083   2148                       rootKey, keyName, true, whatIf, verbose))
  2084   2149               {
  2085   2150                   if (key == null)
  2086   2151                   {
  2087   2152                       error = String.Format(
  2088   2153                           "could not open registry key: {0}\\{1}",
  2089   2154                           rootKey, keyName);
  2090   2155   
  2091   2156                       return false;
  2092   2157                   }
  2093   2158   
  2094         -                using (MockRegistryKey subKey = CreateSubKey(
         2159  +                using (MockRegistryKey subKey = RegistryHelper.CreateSubKey(
  2095   2160                           key, subKeyName, whatIf, verbose))
  2096   2161                   {
  2097   2162                       if (subKey == null)
  2098   2163                       {
  2099   2164                           error = String.Format(
  2100   2165                               "could not create registry key: {0}\\{1}",
  2101   2166                               key, subKeyName);
  2102   2167   
  2103   2168                           return false;
  2104   2169                       }
  2105   2170   
  2106         -                    SetValue(subKey, null, directory, whatIf, verbose);
         2171  +                    RegistryHelper.SetValue(
         2172  +                        subKey, null, directory, whatIf, verbose);
  2107   2173                   }
  2108   2174               }
  2109   2175   
  2110   2176               return true;
  2111   2177           }
  2112   2178   
  2113   2179           ///////////////////////////////////////////////////////////////////////
................................................................................
  2122   2188               bool verbose,
  2123   2189               ref string error
  2124   2190               )
  2125   2191           {
  2126   2192               string keyName = GetAssemblyFoldersKeyName(
  2127   2193                   frameworkName, frameworkVersion, platformName);
  2128   2194   
  2129         -            using (MockRegistryKey key = OpenSubKey(
         2195  +            using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  2130   2196                       rootKey, keyName, false, whatIf, verbose))
  2131   2197               {
  2132   2198                   if (key == null)
  2133   2199                   {
  2134   2200                       error = String.Format(
  2135   2201                           "could not open registry key: {0}\\{1}",
  2136   2202                           rootKey, keyName);
  2137   2203   
  2138   2204                       return false;
  2139   2205                   }
  2140   2206   
  2141         -                DeleteSubKey(key, subKeyName, whatIf, verbose);
         2207  +                RegistryHelper.DeleteSubKey(
         2208  +                    key, subKeyName, whatIf, verbose);
  2142   2209               }
  2143   2210   
  2144   2211               return true;
  2145   2212           }
  2146   2213   
  2147   2214           ///////////////////////////////////////////////////////////////////////
  2148   2215   
................................................................................
  2205   2272               bool whatIf,
  2206   2273               bool verbose,
  2207   2274               ref string error
  2208   2275               )
  2209   2276           {
  2210   2277               string keyName = GetVsKeyName(vsVersion);
  2211   2278   
  2212         -            using (MockRegistryKey key = OpenSubKey(
         2279  +            using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  2213   2280                       rootKey, keyName, false, whatIf, verbose))
  2214   2281               {
  2215   2282                   if (key == null)
  2216   2283                   {
  2217   2284                       error = String.Format(
  2218   2285                           "could not open registry key: {0}\\{1}",
  2219   2286                           rootKey, keyName);
  2220   2287   
  2221   2288                       return false;
  2222   2289                   }
  2223   2290   
  2224         -                using (MockRegistryKey subKey = OpenSubKey(
         2291  +                using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  2225   2292                           key, "DataSources", true, whatIf, verbose))
  2226   2293                   {
  2227   2294                       if (subKey == null)
  2228   2295                       {
  2229   2296                           error = String.Format(
  2230   2297                               "could not open registry key: {0}\\DataSources",
  2231   2298                               key);
  2232   2299   
  2233   2300                           return false;
  2234   2301                       }
  2235   2302   
  2236         -                    using (MockRegistryKey dataSourceKey = CreateSubKey(
         2303  +                    using (MockRegistryKey dataSourceKey = RegistryHelper.CreateSubKey(
  2237   2304                               subKey, dataSourceId.ToString(VsIdFormat), whatIf,
  2238   2305                               verbose))
  2239   2306                       {
  2240   2307                           if (dataSourceKey == null)
  2241   2308                           {
  2242   2309                               error = String.Format(
  2243   2310                                   "could not create registry key: {0}\\{1}",
  2244   2311                                   key, dataSourceId.ToString(VsIdFormat));
  2245   2312   
  2246   2313                               return false;
  2247   2314                           }
  2248   2315   
  2249         -                        SetValue(dataSourceKey, null, String.Format(
         2316  +                        RegistryHelper.SetValue(
         2317  +                            dataSourceKey, null, String.Format(
  2250   2318                               "{0} Database File", ProjectName), whatIf,
  2251   2319                               verbose);
  2252   2320   
  2253         -                        CreateSubKey(dataSourceKey, String.Format(
  2254         -                            "SupportingProviders\\{0}",
         2321  +                        RegistryHelper.CreateSubKey(dataSourceKey,
         2322  +                            String.Format("SupportingProviders\\{0}",
  2255   2323                               dataProviderId.ToString(VsIdFormat)), whatIf,
  2256   2324                               verbose);
  2257   2325                       }
  2258   2326                   }
  2259   2327               }
  2260   2328   
  2261   2329               return true;
................................................................................
  2270   2338               bool whatIf,
  2271   2339               bool verbose,
  2272   2340               ref string error
  2273   2341               )
  2274   2342           {
  2275   2343               string keyName = GetVsKeyName(vsVersion);
  2276   2344   
  2277         -            using (MockRegistryKey key = OpenSubKey(
         2345  +            using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  2278   2346                       rootKey, keyName, false, whatIf, verbose))
  2279   2347               {
  2280   2348                   if (key == null)
  2281   2349                   {
  2282   2350                       error = String.Format(
  2283   2351                           "could not open registry key: {0}\\{1}",
  2284   2352                           rootKey, keyName);
  2285   2353   
  2286   2354                       return false;
  2287   2355                   }
  2288   2356   
  2289         -                using (MockRegistryKey subKey = OpenSubKey(
         2357  +                using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  2290   2358                           key, "DataSources", true, whatIf, verbose))
  2291   2359                   {
  2292   2360                       if (subKey == null)
  2293   2361                       {
  2294   2362                           error = String.Format(
  2295   2363                               "could not open registry key: {0}\\DataSources",
  2296   2364                               key);
  2297   2365   
  2298   2366                           return false;
  2299   2367                       }
  2300   2368   
  2301         -                    DeleteSubKeyTree(
         2369  +                    RegistryHelper.DeleteSubKeyTree(
  2302   2370                           subKey, dataSourceId.ToString(VsIdFormat), whatIf,
  2303   2371                           verbose);
  2304   2372                   }
  2305   2373               }
  2306   2374   
  2307   2375               return true;
  2308   2376           }
................................................................................
  2363   2431               {
  2364   2432                   error = "invalid ADO.NET technology Id";
  2365   2433                   return false;
  2366   2434               }
  2367   2435   
  2368   2436               string keyName = GetVsKeyName(vsVersion);
  2369   2437   
  2370         -            using (MockRegistryKey key = OpenSubKey(
         2438  +            using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  2371   2439                       rootKey, keyName, false, whatIf, verbose))
  2372   2440               {
  2373   2441                   if (key == null)
  2374   2442                   {
  2375   2443                       error = String.Format(
  2376   2444                           "could not open registry key: {0}\\{1}",
  2377   2445                           rootKey, keyName);
  2378   2446   
  2379   2447                       return false;
  2380   2448                   }
  2381   2449   
  2382         -                using (MockRegistryKey subKey = OpenSubKey(
         2450  +                using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  2383   2451                           key, "DataProviders", true, whatIf, verbose))
  2384   2452                   {
  2385   2453                       if (subKey == null)
  2386   2454                       {
  2387   2455                           error = String.Format(
  2388   2456                               "could not open registry key: {0}\\DataProviders",
  2389   2457                               key);
  2390   2458   
  2391   2459                           return false;
  2392   2460                       }
  2393   2461   
  2394         -                    using (MockRegistryKey dataProviderKey = CreateSubKey(
         2462  +                    using (MockRegistryKey dataProviderKey = RegistryHelper.CreateSubKey(
  2395   2463                               subKey, dataProviderId.ToString(VsIdFormat), whatIf,
  2396   2464                               verbose))
  2397   2465                       {
  2398   2466                           if (dataProviderKey == null)
  2399   2467                           {
  2400   2468                               error = String.Format(
  2401   2469                                   "could not create registry key: {0}\\{1}",
  2402   2470                                   key, dataProviderId.ToString(VsIdFormat));
  2403   2471   
  2404   2472                               return false;
  2405   2473                           }
  2406   2474   
  2407         -                        SetValue(dataProviderKey, null, Description, whatIf,
         2475  +                        RegistryHelper.SetValue(
         2476  +                            dataProviderKey, null, Description, whatIf,
  2408   2477                               verbose);
  2409   2478   
  2410         -                        SetValue(dataProviderKey, "InvariantName",
  2411         -                            InvariantName, whatIf, verbose);
         2479  +                        RegistryHelper.SetValue(
         2480  +                            dataProviderKey, "InvariantName", InvariantName,
         2481  +                            whatIf, verbose);
  2412   2482   
  2413         -                        SetValue(dataProviderKey, "Technology",
         2483  +                        RegistryHelper.SetValue(
         2484  +                            dataProviderKey, "Technology",
  2414   2485                               ((Guid)vsAdoNetTechnologyId).ToString(VsIdFormat),
  2415   2486                               whatIf, verbose);
  2416   2487   
  2417         -                        SetValue(dataProviderKey, "CodeBase", fileName, whatIf,
         2488  +                        RegistryHelper.SetValue(
         2489  +                            dataProviderKey, "CodeBase", fileName, whatIf,
  2418   2490                               verbose);
  2419   2491   
  2420         -                        SetValue(dataProviderKey, "FactoryService",
         2492  +                        RegistryHelper.SetValue(
         2493  +                            dataProviderKey, "FactoryService",
  2421   2494                               serviceId.ToString(VsIdFormat), whatIf, verbose);
  2422   2495   
  2423         -                        CreateSubKey(dataProviderKey,
         2496  +                        RegistryHelper.CreateSubKey(dataProviderKey,
  2424   2497                               "SupportedObjects\\DataConnectionUIControl",
  2425   2498                               whatIf, verbose);
  2426   2499   
  2427         -                        CreateSubKey(dataProviderKey,
         2500  +                        RegistryHelper.CreateSubKey(dataProviderKey,
  2428   2501                               "SupportedObjects\\DataConnectionProperties",
  2429   2502                               whatIf, verbose);
  2430   2503   
  2431         -                        CreateSubKey(dataProviderKey,
         2504  +                        RegistryHelper.CreateSubKey(dataProviderKey,
  2432   2505                               "SupportedObjects\\DataConnectionSupport", whatIf,
  2433   2506                               verbose);
  2434   2507   
  2435         -                        CreateSubKey(dataProviderKey,
         2508  +                        RegistryHelper.CreateSubKey(dataProviderKey,
  2436   2509                               "SupportedObjects\\DataObjectSupport", whatIf,
  2437   2510                               verbose);
  2438   2511   
  2439         -                        CreateSubKey(dataProviderKey,
         2512  +                        RegistryHelper.CreateSubKey(dataProviderKey,
  2440   2513                               "SupportedObjects\\DataViewSupport", whatIf,
  2441   2514                               verbose);
  2442   2515                       }
  2443   2516                   }
  2444   2517               }
  2445   2518   
  2446   2519               return true;
................................................................................
  2455   2528               bool whatIf,
  2456   2529               bool verbose,
  2457   2530               ref string error
  2458   2531               )
  2459   2532           {
  2460   2533               string keyName = GetVsKeyName(vsVersion);
  2461   2534   
  2462         -            using (MockRegistryKey key = OpenSubKey(
         2535  +            using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  2463   2536                       rootKey, keyName, false, whatIf, verbose))
  2464   2537               {
  2465   2538                   if (key == null)
  2466   2539                   {
  2467   2540                       error = String.Format(
  2468   2541                           "could not open registry key: {0}\\{1}",
  2469   2542                           rootKey, keyName);
  2470   2543   
  2471   2544                       return false;
  2472   2545                   }
  2473   2546   
  2474         -                using (MockRegistryKey subKey = OpenSubKey(
         2547  +                using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  2475   2548                           key, "DataProviders", true, whatIf, verbose))
  2476   2549                   {
  2477   2550                       if (subKey == null)
  2478   2551                       {
  2479   2552                           error = String.Format(
  2480   2553                               "could not open registry key: {0}\\DataProviders",
  2481   2554                               key);
  2482   2555   
  2483   2556                           return false;
  2484   2557                       }
  2485   2558   
  2486         -                    DeleteSubKeyTree(
         2559  +                    RegistryHelper.DeleteSubKeyTree(
  2487   2560                           subKey, dataProviderId.ToString(VsIdFormat), whatIf,
  2488   2561                           verbose);
  2489   2562                   }
  2490   2563               }
  2491   2564   
  2492   2565               return true;
  2493   2566           }
................................................................................
  2542   2615               bool whatIf,
  2543   2616               bool verbose,
  2544   2617               ref string error
  2545   2618               )
  2546   2619           {
  2547   2620               string keyName = GetVsKeyName(vsVersion);
  2548   2621   
  2549         -            using (MockRegistryKey key = OpenSubKey(
         2622  +            using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  2550   2623                       rootKey, keyName, false, whatIf, verbose))
  2551   2624               {
  2552   2625                   if (key == null)
  2553   2626                   {
  2554   2627                       error = String.Format(
  2555   2628                           "could not open registry key: {0}\\{1}",
  2556   2629                           rootKey, keyName);
  2557   2630   
  2558   2631                       return false;
  2559   2632                   }
  2560   2633   
  2561         -                using (MockRegistryKey subKey = OpenSubKey(
         2634  +                using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  2562   2635                           key, "Packages", true, whatIf, verbose))
  2563   2636                   {
  2564   2637                       if (subKey == null)
  2565   2638                       {
  2566   2639                           error = String.Format(
  2567   2640                               "could not open registry key: {0}\\Packages",
  2568   2641                               key);
  2569   2642   
  2570   2643                           return false;
  2571   2644                       }
  2572   2645   
  2573         -                    using (MockRegistryKey packageKey = CreateSubKey(
         2646  +                    using (MockRegistryKey packageKey = RegistryHelper.CreateSubKey(
  2574   2647                               subKey, packageId.ToString(VsIdFormat), whatIf,
  2575   2648                               verbose))
  2576   2649                       {
  2577   2650                           if (packageKey == null)
  2578   2651                           {
  2579   2652                               error = String.Format(
  2580   2653                                   "could not create registry key: {0}\\{1}",
  2581   2654                                   key, packageId.ToString(VsIdFormat));
  2582   2655   
  2583   2656                               return false;
  2584   2657                           }
  2585   2658   
  2586         -                        SetValue(packageKey, null, String.Format(
         2659  +                        RegistryHelper.SetValue(packageKey, null, String.Format(
  2587   2660                               "{0} Designer Package", ProjectName), whatIf,
  2588   2661                               verbose);
  2589   2662   
  2590         -                        SetValue(packageKey, "Class",
         2663  +                        RegistryHelper.SetValue(packageKey, "Class",
  2591   2664                               "SQLite.Designer.SQLitePackage", whatIf, verbose);
  2592   2665   
  2593         -                        SetValue(packageKey, "CodeBase", fileName, whatIf,
         2666  +                        RegistryHelper.SetValue(packageKey, "CodeBase",
         2667  +                            fileName, whatIf, verbose);
         2668  +
         2669  +                        RegistryHelper.SetValue(packageKey, "ID", 400, whatIf,
  2594   2670                               verbose);
  2595   2671   
  2596         -                        SetValue(packageKey, "ID", 400, whatIf, verbose);
  2597         -
  2598         -                        SetValue(packageKey, "InprocServer32",
         2672  +                        RegistryHelper.SetValue(packageKey, "InprocServer32",
  2599   2673                               Path.Combine(Environment.SystemDirectory,
  2600   2674                                   "mscoree.dll"), whatIf, verbose);
  2601   2675   
  2602         -                        SetValue(packageKey, "CompanyName",
         2676  +                        RegistryHelper.SetValue(packageKey, "CompanyName",
  2603   2677                               "http://system.data.sqlite.org/", whatIf, verbose);
  2604   2678   
  2605         -                        SetValue(packageKey, "MinEdition", "standard", whatIf,
  2606         -                            verbose);
         2679  +                        RegistryHelper.SetValue(packageKey, "MinEdition",
         2680  +                            "standard", whatIf, verbose);
  2607   2681   
  2608         -                        SetValue(packageKey, "ProductName", String.Format(
  2609         -                            "{0} Designer Package", ProjectName), whatIf,
  2610         -                            verbose);
         2682  +                        RegistryHelper.SetValue(packageKey, "ProductName",
         2683  +                            String.Format("{0} Designer Package", ProjectName),
         2684  +                            whatIf, verbose);
  2611   2685   
  2612         -                        SetValue(packageKey, "ProductVersion", "1.0", whatIf,
  2613         -                            verbose);
         2686  +                        RegistryHelper.SetValue(packageKey, "ProductVersion",
         2687  +                            "1.0", whatIf, verbose);
  2614   2688   
  2615         -                        using (MockRegistryKey toolboxKey = CreateSubKey(
         2689  +                        using (MockRegistryKey toolboxKey = RegistryHelper.CreateSubKey(
  2616   2690                                   packageKey, "Toolbox", whatIf, verbose))
  2617   2691                           {
  2618   2692                               if (toolboxKey == null)
  2619   2693                               {
  2620   2694                                   error = String.Format(
  2621   2695                                       "could not create registry key: {0}\\Toolbox",
  2622   2696                                       packageKey);
  2623   2697   
  2624   2698                                   return false;
  2625   2699                               }
  2626   2700   
  2627         -                            SetValue(toolboxKey, "Default Items", 3, whatIf,
         2701  +                            RegistryHelper.SetValue(
         2702  +                                toolboxKey, "Default Items", 3, whatIf,
  2628   2703                                   verbose);
  2629   2704                           }
  2630   2705                       }
  2631   2706                   }
  2632   2707   
  2633         -                using (MockRegistryKey subKey = OpenSubKey(
         2708  +                using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  2634   2709                           key, "Menus", true, whatIf, verbose))
  2635   2710                   {
  2636   2711                       if (subKey == null)
  2637   2712                       {
  2638   2713                           error = String.Format(
  2639   2714                               "could not open registry key: {0}\\Menus",
  2640   2715                               key);
  2641   2716   
  2642   2717                           return false;
  2643   2718                       }
  2644   2719   
  2645         -                    SetValue(subKey, packageId.ToString(VsIdFormat),
  2646         -                        ", 1000, 3", whatIf, verbose);
         2720  +                    RegistryHelper.SetValue(
         2721  +                        subKey, packageId.ToString(VsIdFormat), ", 1000, 3",
         2722  +                        whatIf, verbose);
  2647   2723                   }
  2648   2724   
  2649         -                using (MockRegistryKey subKey = OpenSubKey(
         2725  +                using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  2650   2726                           key, "Services", true, whatIf, verbose))
  2651   2727                   {
  2652   2728                       if (subKey == null)
  2653   2729                       {
  2654   2730                           error = String.Format(
  2655   2731                               "could not open registry key: {0}\\Services",
  2656   2732                               key);
  2657   2733   
  2658   2734                           return false;
  2659   2735                       }
  2660   2736   
  2661         -                    using (MockRegistryKey serviceKey = CreateSubKey(
         2737  +                    using (MockRegistryKey serviceKey = RegistryHelper.CreateSubKey(
  2662   2738                               subKey, serviceId.ToString(VsIdFormat), whatIf,
  2663   2739                               verbose))
  2664   2740                       {
  2665   2741                           if (serviceKey == null)
  2666   2742                           {
  2667   2743                               error = String.Format(
  2668   2744                                   "could not create registry key: {0}\\{1}",
  2669   2745                                   key, serviceId.ToString(VsIdFormat));
  2670   2746   
  2671   2747                               return false;
  2672   2748                           }
  2673   2749   
  2674         -                        SetValue(serviceKey, null,
         2750  +                        RegistryHelper.SetValue(serviceKey, null,
  2675   2751                               packageId.ToString(VsIdFormat), whatIf, verbose);
  2676   2752   
  2677         -                        SetValue(serviceKey, "Name", String.Format(
  2678         -                            "{0} Designer Service", ProjectName), whatIf,
  2679         -                            verbose);
         2753  +                        RegistryHelper.SetValue(serviceKey, "Name",
         2754  +                            String.Format("{0} Designer Service", ProjectName),
         2755  +                            whatIf, verbose);
  2680   2756                       }
  2681   2757                   }
  2682   2758               }
  2683   2759   
  2684   2760               return true;
  2685   2761           }
  2686   2762   
................................................................................
  2694   2770               bool whatIf,
  2695   2771               bool verbose,
  2696   2772               ref string error
  2697   2773               )
  2698   2774           {
  2699   2775               string keyName = GetVsKeyName(vsVersion);
  2700   2776   
  2701         -            using (MockRegistryKey key = OpenSubKey(
         2777  +            using (MockRegistryKey key = RegistryHelper.OpenSubKey(
  2702   2778                       rootKey, keyName, false, whatIf, verbose))
  2703   2779               {
  2704   2780                   if (key == null)
  2705   2781                   {
  2706   2782                       error = String.Format(
  2707   2783                           "could not open registry key: {0}\\{1}",
  2708   2784                           rootKey, keyName);
  2709   2785   
  2710   2786                       return false;
  2711   2787                   }
  2712   2788   
  2713         -                using (MockRegistryKey subKey = OpenSubKey(
         2789  +                using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  2714   2790                           key, "Packages", true, whatIf, verbose))
  2715   2791                   {
  2716   2792                       if (subKey == null)
  2717   2793                       {
  2718   2794                           error = String.Format(
  2719   2795                               "could not open registry key: {0}\\Packages",
  2720   2796                               key);
  2721   2797   
  2722   2798                           return false;
  2723   2799                       }
  2724   2800   
  2725         -                    DeleteSubKeyTree(
         2801  +                    RegistryHelper.DeleteSubKeyTree(
  2726   2802                           key, packageId.ToString(VsIdFormat), whatIf, verbose);
  2727   2803                   }
  2728   2804   
  2729         -                using (MockRegistryKey subKey = OpenSubKey(
         2805  +                using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  2730   2806                           key, "Menus", true, whatIf, verbose))
  2731   2807                   {
  2732   2808                       if (subKey == null)
  2733   2809                       {
  2734   2810                           error = String.Format(
  2735   2811                               "could not open registry key: {0}\\Menus",
  2736   2812                               key);
  2737   2813   
  2738   2814                           return false;
  2739   2815                       }
  2740   2816   
  2741         -                    DeleteValue(subKey, packageId.ToString(VsIdFormat), whatIf,
         2817  +                    RegistryHelper.DeleteValue(
         2818  +                        subKey, packageId.ToString(VsIdFormat), whatIf,
  2742   2819                           verbose);
  2743   2820                   }
  2744   2821   
  2745         -                using (MockRegistryKey subKey = OpenSubKey(
         2822  +                using (MockRegistryKey subKey = RegistryHelper.OpenSubKey(
  2746   2823                           key, "Services", true, whatIf, verbose))
  2747   2824                   {
  2748   2825                       if (subKey == null)
  2749   2826                       {
  2750   2827                           error = String.Format(
  2751   2828                               "could not open registry key: {0}\\Services",
  2752   2829                               key);
  2753   2830   
  2754   2831                           return false;
  2755   2832                       }
  2756   2833   
  2757         -                    DeleteSubKeyTree(
         2834  +                    RegistryHelper.DeleteSubKeyTree(
  2758   2835                           subKey, serviceId.ToString(VsIdFormat), whatIf,
  2759   2836                           verbose);
  2760   2837                   }
  2761   2838               }
  2762   2839   
  2763   2840               return true;
  2764   2841           }
................................................................................
  4027   4104                           traceCallback, null, error, traceCategory,
  4028   4105                           MessageBoxButtons.OK, MessageBoxIcon.Error);
  4029   4106   
  4030   4107                       return 1;
  4031   4108                   }
  4032   4109               }
  4033   4110               #endregion
         4111  +
         4112  +            ///////////////////////////////////////////////////////////////////
         4113  +
         4114  +            TraceOps.Trace(traceCallback, String.Format(
         4115  +                "subKeysCreated = {0}, subKeysDeleted = {1}, " +
         4116  +                "keyValuesSet = {2}, keyValuesDeleted = {3}",
         4117  +                RegistryHelper.SubKeysCreated, RegistryHelper.SubKeysDeleted,
         4118  +                RegistryHelper.KeyValuesSet, RegistryHelper.KeyValuesDeleted),
         4119  +                traceCategory);
  4034   4120   
  4035   4121               ///////////////////////////////////////////////////////////////////
  4036   4122   
  4037   4123               return 0;
  4038   4124           }
  4039   4125           #endregion
  4040   4126       }
  4041   4127       #endregion
  4042   4128   }