public override bool Equals(object obj)
 {
     return(obj is TranslateSubtitlesFileToNewFile file &&
            ToTranslate.Equals(file.ToTranslate) &&
            TargetLanguage.Equals(file.TargetLanguage) &&
            OutputFile.Equals(file.OutputFile));
 }
        public bool Execute()
        {
            try
            {
                string java;
                if (!string.IsNullOrEmpty(JavaExecutable))
                {
                    java = JavaExecutable;
                }
                else
                {
                    string javaHome = JavaHome;
                    java = Path.Combine(Path.Combine(javaHome, "bin"), "java.exe");
                }

                List <string> arguments = new List <string>();
                arguments.Add("-cp");
                arguments.Add(ToolPath);
                arguments.Add("org.antlr.v4.CSharpTool");

                arguments.Add("-o");
                arguments.Add(OutputPath);

                if (GenerateListener)
                {
                    arguments.Add("-listener");
                }
                else
                {
                    arguments.Add("-no-listener");
                }

                if (GenerateVisitor)
                {
                    arguments.Add("-visitor");
                }
                else
                {
                    arguments.Add("-no-visitor");
                }

                if (ForceAtn)
                {
                    arguments.Add("-force-atn");
                }

                if (AbstractGrammar)
                {
                    arguments.Add("-Dabstract=true");
                }

                if (!string.IsNullOrEmpty(TargetLanguage))
                {
                    string framework = TargetFrameworkVersion;
                    if (string.IsNullOrEmpty(framework))
                    {
                        framework = "v2.0";
                    }
                    if (framework == "v4.5.1")
                    {
                        framework = "v4.5";
                    }

                    string language;
                    if (TargetLanguage.Equals("CSharp"))
                    {
                        language = TargetLanguage + '_' + framework.Replace('.', '_');
                    }
                    else
                    {
                        language = TargetLanguage;
                    }

                    arguments.Add("-Dlanguage=" + language);
                }

                if (!string.IsNullOrEmpty(TargetNamespace))
                {
                    arguments.Add("-package");
                    arguments.Add(TargetNamespace);
                }

                arguments.AddRange(SourceCodeFiles);

                ProcessStartInfo startInfo = new ProcessStartInfo(java, JoinArguments(arguments))
                {
                    UseShellExecute        = false,
                    CreateNoWindow         = true,
                    RedirectStandardInput  = true,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                };

                this.BuildMessages.Add(new BuildMessage(TraceLevel.Info, "Executing command: \"" + startInfo.FileName + "\" " + startInfo.Arguments, "", 0, 0));

                Process process = new Process();
                process.StartInfo           = startInfo;
                process.ErrorDataReceived  += HandleErrorDataReceived;
                process.OutputDataReceived += HandleOutputDataReceived;
                process.Start();
                process.BeginErrorReadLine();
                process.BeginOutputReadLine();
                process.StandardInput.Close();
                process.WaitForExit();

                return(process.ExitCode == 0);
                //using (LoggingTraceListener traceListener = new LoggingTraceListener(_buildMessages))
                //{
                //    SetTraceListener(traceListener);
                //    ProcessArgs(args.ToArray());
                //    process();
                //}

                //_generatedCodeFiles.AddRange(GetGeneratedFiles().Where(file => LanguageSourceExtensions.Contains(Path.GetExtension(file), StringComparer.OrdinalIgnoreCase)));

                //int errorCount = GetNumErrors();
                //return errorCount == 0;
            }
            catch (Exception e)
            {
                if (e is TargetInvocationException && e.InnerException != null)
                {
                    e = e.InnerException;
                }

                _buildMessages.Add(new BuildMessage(e.Message));
                throw;
            }
        }