Skip to content

Commit

Permalink
Removing is operator in preference to as operator for .NET code
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed Mar 17, 2020
1 parent f336673 commit 50749de
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions dotnet/src/support/Events/EventFiringWebDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1419,20 +1419,6 @@ public void Submit()
}
}

public override bool Equals(object obj)
{
if (!(obj is IWebElement))
return false;

IWebElement other = (IWebElement)obj;
if(other is IWrapsElement wrapper)
{
other = ((IWrapsElement)wrapper).WrappedElement;
}

return underlyingElement.Equals(other);
}

/// <summary>
/// Click this element. If this causes a new page to load, this method will block until
/// the page has loaded. At this point, you should discard all references to this element
Expand Down Expand Up @@ -1574,6 +1560,28 @@ public ReadOnlyCollection<IWebElement> FindElements(By by)

return wrappedElementList.AsReadOnly();
}

/// <summary>
/// Determines whether the specified <see cref="EventFiringWebElement"/> is equal to the current <see cref="EventFiringWebElement"/>.
/// </summary>
/// <param name="obj">The <see cref="EventFiringWebElement"/> to compare to the current <see cref="EventFiringWebElement"/>.</param>
/// <returns><see langword="true"/> if the specified <see cref="EventFiringWebElement"/> is equal to the current <see cref="EventFiringWebElement"/>; otherwise, <see langword="false"/>.</returns>
public override bool Equals(object obj)
{
IWebElement other = obj as IWebElement;
if (other == null)
{
return false;
}

IWrapsElement otherWrapper = other as IWrapsElement;
if (otherWrapper != null)
{
other = otherWrapper.WrappedElement;
}

return underlyingElement.Equals(other);
}
}
}
}

0 comments on commit 50749de

Please sign in to comment.