mirror of https://github.com/dahall/Vanara.git
Improved Equals method on SafeHANDLE
parent
70cb69039a
commit
6595d81b92
|
@ -1981,7 +1981,20 @@ namespace Vanara.PInvoke
|
|||
/// <summary>Determines whether the specified <see cref="System.Object"/>, is equal to this instance.</summary>
|
||||
/// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
|
||||
/// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.</returns>
|
||||
public override bool Equals(object obj) => obj is SafeHANDLE h ? Equals(h) : base.Equals(obj);
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
switch (obj)
|
||||
{
|
||||
case IHandle ih:
|
||||
return handle.Equals(ih.DangerousGetHandle());
|
||||
case SafeHandle sh:
|
||||
return handle.Equals(sh.DangerousGetHandle());
|
||||
case IntPtr p:
|
||||
return handle.Equals(p);
|
||||
default:
|
||||
return base.Equals(obj);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Returns a hash code for this instance.</summary>
|
||||
/// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns>
|
||||
|
|
Loading…
Reference in New Issue