Пример #1
0
        string ShellOpenSearch(string className)
        {
            using (RegistryKey rk = Registry.ClassesRoot.OpenSubKey(className + "\\shell\\open\\command", false))
            {
                if (rk == null)
                {
                    return(null);
                }

                string cmdLine = rk.GetValue("") as string;

                if (string.IsNullOrEmpty(cmdLine))
                {
                    return(null);
                }

                string program, args;
                if (!SvnTools.TrySplitCommandLine(cmdLine, SubstituteEmpty, out program, out args))
                {
                    return(null);
                }
                else
                {
                    return(program);
                }
            }
        }
Пример #2
0
        public void SplitPaths()
        {
            string app, args;

            Assert.That(SvnTools.TrySplitCommandLine("wscript script", out app, out args));
            Assert.That(app, Is.EqualTo("wscript"));
            Assert.That(args, Is.EqualTo("script"));
            Assert.That(SvnTools.TryFindApplication("wscript", out app));
            Assert.That(File.Exists(app));
            Assert.That(Path.GetFileName(app).ToLowerInvariant(), Is.EqualTo("wscript.exe"));
        }
Пример #3
0
        private bool Substitute(string reference, AnkhDiffToolArgs args, DiffToolMode toolMode, out string program, out string arguments)
        {
            if (string.IsNullOrEmpty(reference))
            {
                throw new ArgumentNullException("reference");
            }
            else if (args == null)
            {
                throw new ArgumentNullException("args");
            }

            // Ok: We received a string with a program and arguments and windows
            // wants a program and arguments separated. Let's find the program before substituting

            reference = reference.TrimStart();

            program   = null;
            arguments = null;

            string app;

            if (!string.IsNullOrEmpty(app = AnkhDiffTool.GetToolNameFromTemplate(reference)))
            {
                // We have a predefined template. Just use it
                AnkhDiffTool tool = GetAppItem(app, toolMode);

                if (tool == null)
                {
                    return(false);
                }
                else if (!tool.IsAvailable)
                {
                    return(false);
                }

                program   = SubstituteArguments(tool.Program, args, toolMode);
                arguments = SubstituteArguments(tool.Arguments, args, toolMode);

                return(!String.IsNullOrEmpty(program) && File.Exists(program));
            }
            else if (!SvnTools.TrySplitCommandLine(reference, SubstituteEmpty, out program, out arguments))
            {
                return(false);
            }

            program   = SubstituteArguments(program, args, toolMode);
            arguments = SubstituteArguments(arguments, args, toolMode);

            return(true);
        }