From a8f55538933c0d1bbe31da4a8f17444b572724e3 Mon Sep 17 00:00:00 2001 From: gumbarros Date: Thu, 5 Dec 2024 23:21:59 -0300 Subject: [PATCH] Use `params IEnumerable args` --- .../Services/DataDictionaryServiceBase.cs | 2 +- src/Core/DataDictionary/Services/FieldService.cs | 4 ++-- .../ExpressionProviderEnumerableExtensions.cs | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Core/DataDictionary/Services/DataDictionaryServiceBase.cs b/src/Core/DataDictionary/Services/DataDictionaryServiceBase.cs index b46eaa2cf..fea94ce64 100644 --- a/src/Core/DataDictionary/Services/DataDictionaryServiceBase.cs +++ b/src/Core/DataDictionary/Services/DataDictionaryServiceBase.cs @@ -84,7 +84,7 @@ public bool ValidateName(string name) return validationDictionary.IsValid; } - protected static bool ValidateExpression(string value, params string[] args) + protected static bool ValidateExpression(string value, params IEnumerable args) { return args.Any(value.StartsWith); } diff --git a/src/Core/DataDictionary/Services/FieldService.cs b/src/Core/DataDictionary/Services/FieldService.cs index 8c9b73801..0493f54ac 100644 --- a/src/Core/DataDictionary/Services/FieldService.cs +++ b/src/Core/DataDictionary/Services/FieldService.cs @@ -193,8 +193,8 @@ private async ValueTask ValidateFieldAsync(FormElement formElement, FormEl private void ValidateExpressions(FormElementField field) { - var syncProviders = expressionProviders.GetSyncProvidersPrefixes(); - var asyncProviders = expressionProviders.GetAsyncProvidersPrefixes(); + var syncProviders = expressionProviders.GetSyncProvidersPrefixes().ToArray(); + var asyncProviders = expressionProviders.GetAsyncProvidersPrefixes().ToArray(); if (string.IsNullOrWhiteSpace(field.VisibleExpression)) AddError(nameof(field.VisibleExpression), StringLocalizer["Required [VisibleExpression] field"]); diff --git a/src/Core/Extensions/ExpressionProviderEnumerableExtensions.cs b/src/Core/Extensions/ExpressionProviderEnumerableExtensions.cs index 816435bf2..bb2c47f46 100644 --- a/src/Core/Extensions/ExpressionProviderEnumerableExtensions.cs +++ b/src/Core/Extensions/ExpressionProviderEnumerableExtensions.cs @@ -6,17 +6,17 @@ namespace JJMasterData.Core.Extensions; public static class ExpressionProviderEnumerableExtensions { - public static string[] GetProvidersPrefixes(this IEnumerable expressionProviders) + public static IEnumerable GetProvidersPrefixes(this IEnumerable expressionProviders) { - return expressionProviders.Select(p => p.Prefix).ToArray(); + return expressionProviders.Select(p => p.Prefix); } - public static string[] GetAsyncProvidersPrefixes(this IEnumerable expressionProviders) + public static IEnumerable GetAsyncProvidersPrefixes(this IEnumerable expressionProviders) { - return expressionProviders.Where(p => p is IAsyncExpressionProvider).Select(p => p.Prefix).ToArray(); + return expressionProviders.OfType().Select(p => p.Prefix); } - public static string[] GetSyncProvidersPrefixes(this IEnumerable expressionProviders) + public static IEnumerable GetSyncProvidersPrefixes(this IEnumerable expressionProviders) { - return expressionProviders.Where(p => p is ISyncExpressionProvider).Select(p => p.Prefix).ToArray(); + return expressionProviders.OfType().Select(p => p.Prefix); } } \ No newline at end of file