From f86a38b113709c2ed344c145eba192b62f8409ec Mon Sep 17 00:00:00 2001 From: dahall Date: Thu, 6 Jan 2022 15:09:53 -0700 Subject: [PATCH] Applied new lang constructs to CLIPFORMAT --- PInvoke/Shared/WinUser/CLIPFORMAT.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/PInvoke/Shared/WinUser/CLIPFORMAT.cs b/PInvoke/Shared/WinUser/CLIPFORMAT.cs index cdbeb433..9997efcc 100644 --- a/PInvoke/Shared/WinUser/CLIPFORMAT.cs +++ b/PInvoke/Shared/WinUser/CLIPFORMAT.cs @@ -47,14 +47,14 @@ namespace Vanara.PInvoke /// public int CompareTo(object obj) { - if (!(obj is IConvertible c)) throw new ArgumentException(@"Object cannot be converted to a UInt16 value for comparison.", nameof(obj)); + if (obj is not IConvertible c) throw new ArgumentException(@"Object cannot be converted to a UInt16 value for comparison.", nameof(obj)); return _value.CompareTo(c.ToUInt16(null)); } /// 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. - public override bool Equals(object obj) => obj is IConvertible c ? _value.Equals(c.ToUInt16(null)) : false; + public override bool Equals(object obj) => obj is IConvertible c && _value.Equals(c.ToUInt16(null)); /// Indicates whether the current object is equal to another object of the same type. /// An object to compare with this object. @@ -75,7 +75,7 @@ namespace Vanara.PInvoke return $"{fi.Name} ({HexStr(this)})"; return HexStr(this); - string HexStr(in CLIPFORMAT cf) => string.Format(CultureInfo.InvariantCulture, "0x{0:X4}", cf._value); + static string HexStr(in CLIPFORMAT cf) => string.Format(CultureInfo.InvariantCulture, "0x{0:X4}", cf._value); } /// Implements the operator ==. @@ -105,22 +105,22 @@ namespace Vanara.PInvoke /// Performs an implicit conversion from to . /// The value. /// The result of the conversion. - public static implicit operator CLIPFORMAT(ushort value) => new CLIPFORMAT(value); + public static implicit operator CLIPFORMAT(ushort value) => new(value); /// Performs an implicit conversion from to . /// The value. /// The result of the conversion. - public static implicit operator CLIPFORMAT(short value) => new CLIPFORMAT(unchecked((ushort)value)); + public static implicit operator CLIPFORMAT(short value) => new(unchecked((ushort)value)); /// Performs an implicit conversion from to . /// The value. /// The result of the conversion. - public static implicit operator CLIPFORMAT(uint value) => new CLIPFORMAT((ushort)value); + public static implicit operator CLIPFORMAT(uint value) => new((ushort)value); /// Performs an implicit conversion from to . /// The value. /// The result of the conversion. - public static implicit operator CLIPFORMAT(int value) => new CLIPFORMAT((ushort)value); + public static implicit operator CLIPFORMAT(int value) => new((ushort)value); /// Performs an explicit conversion from to . /// The value.