public Response Execute(Command commandToExecute) { Response result = null; try { if (commandToExecute.Name == DriverCommand.NewSession) { Service?.Start(); RealExecutor = ModifyNewSessionHttpRequestHeader(RealExecutor); } result = RealExecutor.Execute(commandToExecute); return(result); } catch (Exception e) { if ((commandToExecute.Name == DriverCommand.NewSession)) { Service?.Dispose(); } throw; } finally { if (result != null && result.Status != WebDriverResult.Success && commandToExecute.Name == DriverCommand.NewSession) { Dispose(); } if (commandToExecute.Name == DriverCommand.Quit) { Dispose(); } } }
public Response Execute(Command commandToExecute) { Response result = null; if (commandToExecute.Name == DriverCommand.NewSession && this.Service != null) { Service.Start(); } try { result = RealExecutor.Execute(commandToExecute); return(result); } catch (Exception e) { if ((commandToExecute.Name == DriverCommand.NewSession) && (Service != null)) { Service.Dispose(); } throw e; } finally { if (result != null && result.Status != WebDriverResult.Success && commandToExecute.Name == DriverCommand.NewSession && Service != null) { Service.Dispose(); } if (commandToExecute.Name == DriverCommand.Quit && Service != null) { Service.Dispose(); } } }