static bool ShouldExitLaunch( TryResolveTool tryResolveTool, string targetFile, [NotNullWhen(false)] out ResolvedTool?tool, [NotNullWhen(true)] out LaunchResult?result) { if (Disabled) { result = LaunchResult.Disabled; tool = null; return(true); } if (!tryResolveTool(out tool)) { result = LaunchResult.NoDiffToolFound; return(true); } if (!TryCreate(tool, targetFile)) { result = LaunchResult.NoEmptyFileForExtension; return(true); } result = null; return(false); }
static LaunchResult InnerLaunch(TryResolveTool tryResolveTool, string tempFile, string targetFile) { if (ShouldExitLaunch(tryResolveTool, targetFile, out var tool, out var result)) { DiffEngineTray.AddMove(tempFile, targetFile, null, null, false, null); return(result.Value); } tool.CommandAndArguments(tempFile, targetFile, out var arguments, out var command); if (ProcessCleanup.TryGetProcessInfo(command, out var processCommand)) { if (tool.AutoRefresh) { DiffEngineTray.AddMove(tempFile, targetFile, tool.ExePath, arguments, tool.IsMdi !, processCommand.Process); return(LaunchResult.AlreadyRunningAndSupportsRefresh); } KillIfMdi(tool, command); } if (MaxInstance.Reached()) { DiffEngineTray.AddMove(tempFile, targetFile, tool.ExePath, arguments, tool.IsMdi !, null); return(LaunchResult.TooManyRunningDiffTools); } var processId = LaunchProcess(tool, arguments); DiffEngineTray.AddMove(tempFile, targetFile, tool.ExePath, arguments, !tool.IsMdi, processId); return(LaunchResult.StartedNewInstance); }