private static string GetPath(PathInfo pathInfo, out RegistryKey subKey)
        {
            //Console.WriteLine(
            //   "Checking subKey {0} in {1}",
            //   pathInfo.KeyPath,
            //   pathInfo.RootKey.Name);
            //Console.ReadLine();

            subKey = pathInfo.RootKey.OpenSubKey(pathInfo.KeyPath, true);

            if (subKey == null)
            {
                //Console.WriteLine("subKey == null ({0})", pathInfo.KeyPath);
                //Console.ReadLine();
                return null;
            }

            var path = subKey.GetValue(pathInfo.KeyName);

            if (path == null)
            {
                return null;
            }

            //Console.WriteLine("Old path: " + path);
            //Console.ReadLine();
            return path.ToString();
        }
Beispiel #2
0
        private static void RunInstall(string command, string snippetsPath)
        {
            try
            {
                // Console.WriteLine("RunInstall");
                // Console.ReadLine();

                PathInfo pathInfo = null;

                switch (command)
                {
                case InstallActionVs10User:
                    pathInfo = SnippetsRegistryPathInfoVs10User;
                    break;

                case InstallActionVs10Machine:
                    pathInfo = SnippetsRegistryPathInfoVs10Machine;
                    break;

                case InstallActionVs08User:
                    pathInfo = SnippetsRegistryPathInfoVs08User;
                    break;

                case InstallActionVs08Machine:
                    pathInfo = SnippetsRegistryPathInfoVs08Machine;
                    break;
                }

                if (pathInfo == null)
                {
                    return;
                }

                RegistryKey subKey;
                var         snippetsPaths = GetPath(pathInfo, out subKey);

                if (string.IsNullOrEmpty(snippetsPaths) ||
                    subKey == null)
                {
                    return;
                }

                if (!snippetsPaths.EndsWith(";"))
                {
                    snippetsPaths = snippetsPaths + ";";
                }

                if (!snippetsPaths.Contains(snippetsPath))
                {
                    // Console.WriteLine("New path: " + snippetsPaths + snippetsPath + ";");
                    // Console.ReadLine();
                    subKey.SetValue(pathInfo.KeyName, snippetsPaths + snippetsPath + ";");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(
                    "Error when installing snippets. Please contact [email protected]. Sorry...");
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }
        }
        private static string GetPath(PathInfo pathInfo, out RegistryKey subKey)
        {
#if LOG
            _report.Append(string.Format(
                "Checking subKey {0} in {1}",
               pathInfo.KeyPath,
               pathInfo.RootKey.Name));
            _report.Append(Environment.NewLine);
#endif
            //Console.WriteLine(
            //   "Checking subKey {0} in {1}",
            //   pathInfo.KeyPath,
            //   pathInfo.RootKey.Name);
            //Console.ReadLine();

            subKey = pathInfo.RootKey.OpenSubKey(pathInfo.KeyPath, true);

            if (subKey == null)
            {
#if LOG
                _report.Append(string.Format("subKey == null ({0})", pathInfo.KeyPath));
                _report.Append(Environment.NewLine);
#endif
                //Console.WriteLine("subKey == null ({0})", pathInfo.KeyPath);
                //Console.ReadLine();
                return null;
            }

            var path = subKey.GetValue(pathInfo.KeyName);

            if (path == null)
            {
                return null;
            }

#if LOG
            _report.Append("Old path: " + path);
            _report.Append(Environment.NewLine);
#endif
            //Console.WriteLine("Old path: " + path);
            //Console.ReadLine();
            return path.ToString();
        }
Beispiel #4
0
        private static string GetPath(PathInfo pathInfo, out RegistryKey subKey)
        {
            Log(string.Format("Checking subKey {0} in {1}",
               pathInfo.KeyPath,
               pathInfo.RootKey.Name));
            
            subKey = pathInfo.RootKey.OpenSubKey(pathInfo.KeyPath, true);

            if (subKey == null)
            {
                Log(string.Format("subKey == null ({0})", pathInfo.KeyPath));
                return null;
            }

            var path = subKey.GetValue(pathInfo.KeyName);

            if (path == null)
            {
                return null;
            }

            Log("Old path: " + path);
            return path.ToString();
        }