From f3c9ff52bfe4e98e8a4744b91f54dd3f17c6f778 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Fri, 14 Mar 2025 21:47:32 +0100 Subject: [PATCH] Added GetAllEnumValues to common tools --- app/MindWork AI Studio/Tools/CommonTools.cs | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 app/MindWork AI Studio/Tools/CommonTools.cs diff --git a/app/MindWork AI Studio/Tools/CommonTools.cs b/app/MindWork AI Studio/Tools/CommonTools.cs new file mode 100644 index 00000000..26150880 --- /dev/null +++ b/app/MindWork AI Studio/Tools/CommonTools.cs @@ -0,0 +1,22 @@ +using System.Text; + +namespace AIStudio.Tools; + +public static class CommonTools +{ + /// + /// Get all the values (the names) of an enum as a string, separated by commas. + /// + /// The enum type to get the values of. + /// The values to exclude from the result. + /// The values of the enum as a string, separated by commas. + public static string GetAllEnumValues(params TEnum[] exceptions) where TEnum : struct, Enum + { + var sb = new StringBuilder(); + foreach (var value in Enum.GetValues()) + if(!exceptions.Contains(value)) + sb.Append(value).Append(", "); + + return sb.ToString(); + } +} \ No newline at end of file