private Application RecycleOrHandleNone(string name, ViableProcessFilter filter, HandlerForNoMatchingProcesses handler, FailureToLaunchHandler failureToLaunchHandler) { Process[] processes = Process.GetProcessesByName(name); List <Process> viableProcesses = filter(processes); if (viableProcesses.Count > 1) { failureToLaunchHandler("Cannot choose between two or more processes called " + name); return(null); } if (viableProcesses.Count < 1) { return(handler("Cannot find any processes called " + name)); } return(new Application(viableProcesses[0], Timeout)); }
private Application RecycleOrHandleNone(string name, ViableProcessFilter filter, HandlerForNoMatchingProcesses handler, FailureToLaunchHandler failureToLaunchHandler) { Process[] processes = Process.GetProcessesByName(name); List<Process> viableProcesses = filter(processes); if (viableProcesses.Count > 1) { failureToLaunchHandler("Cannot choose between two or more processes called " + name); return null; } if (viableProcesses.Count < 1) { return handler("Cannot find any processes called " + name); } return new Application(viableProcesses[0], Timeout); }