Skip to content

Commit 52cb35c

Browse files
committed
[dotnet] Fix design of raising of events when driver service starts/started
1 parent 3744929 commit 52cb35c

File tree

1 file changed

+3
-32
lines changed

1 file changed

+3
-32
lines changed

dotnet/src/webdriver/DriverService.cs

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,12 @@ public void Start()
243243
this.driverServiceProcess.StartInfo.UseShellExecute = false;
244244
this.driverServiceProcess.StartInfo.CreateNoWindow = this.HideCommandPromptWindow;
245245

246-
DriverProcessStartingEventArgs eventArgs = new DriverProcessStartingEventArgs(this.driverServiceProcess.StartInfo);
247-
this.OnDriverProcessStarting(eventArgs);
246+
this.DriverProcessStarting?.Invoke(this, new DriverProcessStartingEventArgs(this.driverServiceProcess.StartInfo));
248247

249248
this.driverServiceProcess.Start();
250249
bool serviceAvailable = this.WaitForServiceInitialization();
251-
DriverProcessStartedEventArgs processStartedEventArgs = new DriverProcessStartedEventArgs(this.driverServiceProcess);
252-
this.OnDriverProcessStarted(processStartedEventArgs);
250+
251+
this.DriverProcessStarted?.Invoke(this, new DriverProcessStartedEventArgs(this.driverServiceProcess));
253252

254253
if (!serviceAvailable)
255254
{
@@ -280,34 +279,6 @@ protected virtual void Dispose(bool disposing)
280279
}
281280
}
282281

283-
/// <summary>
284-
/// Raises the <see cref="DriverProcessStarting"/> event.
285-
/// </summary>
286-
/// <param name="eventArgs">A <see cref="DriverProcessStartingEventArgs"/> that contains the event data.</param>
287-
protected void OnDriverProcessStarting(DriverProcessStartingEventArgs eventArgs)
288-
{
289-
if (eventArgs == null)
290-
{
291-
throw new ArgumentNullException(nameof(eventArgs), "eventArgs must not be null");
292-
}
293-
294-
this.DriverProcessStarting?.Invoke(this, eventArgs);
295-
}
296-
297-
/// <summary>
298-
/// Raises the <see cref="DriverProcessStarted"/> event.
299-
/// </summary>
300-
/// <param name="eventArgs">A <see cref="DriverProcessStartedEventArgs"/> that contains the event data.</param>
301-
protected void OnDriverProcessStarted(DriverProcessStartedEventArgs eventArgs)
302-
{
303-
if (eventArgs == null)
304-
{
305-
throw new ArgumentNullException(nameof(eventArgs), "eventArgs must not be null");
306-
}
307-
308-
this.DriverProcessStarted?.Invoke(this, eventArgs);
309-
}
310-
311282
/// <summary>
312283
/// Stops the DriverService.
313284
/// </summary>

0 commit comments

Comments
 (0)