Skip to content

Commit

Permalink
Use params IEnumerable<string> args
Browse files Browse the repository at this point in the history
  • Loading branch information
gumbarros committed Dec 6, 2024
1 parent b0ebab0 commit a8f5553
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> args)
{
return args.Any(value.StartsWith);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Core/DataDictionary/Services/FieldService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ private async ValueTask<bool> 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"]);
Expand Down
12 changes: 6 additions & 6 deletions src/Core/Extensions/ExpressionProviderEnumerableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ namespace JJMasterData.Core.Extensions;

public static class ExpressionProviderEnumerableExtensions
{
public static string[] GetProvidersPrefixes(this IEnumerable<IExpressionProvider> expressionProviders)
public static IEnumerable<string> GetProvidersPrefixes(this IEnumerable<IExpressionProvider> expressionProviders)
{
return expressionProviders.Select(p => p.Prefix).ToArray();
return expressionProviders.Select(p => p.Prefix);
}
public static string[] GetAsyncProvidersPrefixes(this IEnumerable<IExpressionProvider> expressionProviders)
public static IEnumerable<string> GetAsyncProvidersPrefixes(this IEnumerable<IExpressionProvider> expressionProviders)
{
return expressionProviders.Where(p => p is IAsyncExpressionProvider).Select(p => p.Prefix).ToArray();
return expressionProviders.OfType<IAsyncExpressionProvider>().Select(p => p.Prefix);
}

public static string[] GetSyncProvidersPrefixes(this IEnumerable<IExpressionProvider> expressionProviders)
public static IEnumerable<string> GetSyncProvidersPrefixes(this IEnumerable<IExpressionProvider> expressionProviders)
{
return expressionProviders.Where(p => p is ISyncExpressionProvider).Select(p => p.Prefix).ToArray();
return expressionProviders.OfType<ISyncExpressionProvider>().Select(p => p.Prefix);
}
}

0 comments on commit a8f5553

Please sign in to comment.