From d6a7e5f4aa933e2d9ad51747d50dc3a60d349a96 Mon Sep 17 00:00:00 2001 From: dahall Date: Mon, 4 May 2020 10:55:43 -0600 Subject: [PATCH] Added IEquatable implementation --- PInvoke/Shared/WinError/NTStatus.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/PInvoke/Shared/WinError/NTStatus.cs b/PInvoke/Shared/WinError/NTStatus.cs index 8a84df54..8f8daf72 100644 --- a/PInvoke/Shared/WinError/NTStatus.cs +++ b/PInvoke/Shared/WinError/NTStatus.cs @@ -36,7 +36,7 @@ namespace Vanara.PInvoke [StructLayout(LayoutKind.Sequential)] [TypeConverter(typeof(NTStatusTypeConverter))] [PInvokeData("winerr.h")] - public partial struct NTStatus : IComparable, IComparable, IEquatable, IConvertible, IErrorProvider + public partial struct NTStatus : IComparable, IComparable, IEquatable, IEquatable, IConvertible, IErrorProvider { internal readonly int _value; @@ -393,6 +393,11 @@ namespace Vanara.PInvoke : throw new ArgumentException(@"Object cannot be converted to a UInt32 value for comparison.", nameof(obj)); } + /// Indicates whether the current object is equal to an . + /// An object to compare with this object. + /// true if the current object is equal to the parameter; otherwise, false. + public bool Equals(int other) => other == _value; + /// Determines whether the specified , is equal to this instance. /// The to compare with this instance. /// true if the specified is equal to this instance; otherwise, false. @@ -408,11 +413,7 @@ namespace Vanara.PInvoke /// The associated or null if this NTStatus is not a failure. [SecurityCritical] [SecuritySafeCritical] - public Exception GetException(string message = null) - { - if (!Failed) return null; - return ToHRESULT().GetException(); - } + public Exception GetException(string message = null) => !Failed ? null : ToHRESULT().GetException(); /// Returns a hash code for this instance. /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.