From 7b1fc4439058a3e8c6d79042d2a42b3022adb885 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Wed, 26 May 2021 14:58:55 -0400 Subject: [PATCH] implement EqualsAny method to check equality with any one of the values in an array --- .../UniversalEditor.Core/ExtensionMethods.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Libraries/UniversalEditor.Core/ExtensionMethods.cs b/Libraries/UniversalEditor.Core/ExtensionMethods.cs index 98e9bd9d..cc21bb48 100644 --- a/Libraries/UniversalEditor.Core/ExtensionMethods.cs +++ b/Libraries/UniversalEditor.Core/ExtensionMethods.cs @@ -118,6 +118,29 @@ namespace UniversalEditor return true; } + /// + /// Returns if is equal + /// to any one of the values in . + /// + /// true, if a match was found; false otherwise. + /// The value to test. + /// + /// An array of items of type to check equality + /// against . + /// + public static bool EqualsAny(this IEquatable value, params T[] anyOf) + { + for (int i = 0; i < anyOf.Length; i++) + { + T any = anyOf[i]; + if (value.Equals(any)) + { + return true; + } + } + return false; + } + public static bool ContainsAny(this string value, params string[] anyOf) { bool result;