示例#1
0
        internal void StartProcess()
        {
            process = new System.Diagnostics.Process();
            process.StartInfo.StandardOutputEncoding = Encoding.UTF8;
            process.StartInfo.StandardErrorEncoding  = Encoding.UTF8;
            process.StartInfo.FileName               = ReferenceSearchEngine.RipGrepPath;
            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.RedirectStandardError  = true;
            process.StartInfo.RedirectStandardInput  = false;
            process.StartInfo.CreateNoWindow         = true;
            process.StartInfo.WindowStyle            = System.Diagnostics.ProcessWindowStyle.Hidden;
            var args = Argument;

            if (IgnoreDirectory != null)
            {
                args += string.Format(" -g {0} ", ReferenceSearchEngine.Quote("!" + IgnoreDirectory));
            }
            if (TargetGUIDs.Count == 1)
            {
                args += TargetGUIDs[0];
            }
            else
            {
                args += ReferenceSearchEngine.Quote(string.Join("|", TargetGUIDs.ToArray()));
            }
            args += string.Format(" {0}", ReferenceSearchEngine.Quote(SearchDirectory));
            // ReferenceSearchEngine.Log(args);
            process.StartInfo.Arguments = args;
            // process.EnableRaisingEvents = true;
            // process.OutputDataReceived += OnStdout;
            process.ErrorDataReceived += OnStderr;

            process.Start();
            // process.BeginOutputReadLine();
            process.BeginErrorReadLine();
        }