From 36309013be58ea577b724fb366f35959bf3d1018 Mon Sep 17 00:00:00 2001 From: Sakari Malkki Date: Fri, 13 Sep 2024 11:01:24 +0300 Subject: [PATCH] Removes utility method with a linq function --- .../ContentValidator.UtilityMethods.cs | 22 ++----------------- .../ContentValidator.ValidationFunctions.cs | 3 +-- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/Px.Utils/Validation/ContentValidation/ContentValidator.UtilityMethods.cs b/Px.Utils/Validation/ContentValidation/ContentValidator.UtilityMethods.cs index 1d77178..4f364c1 100644 --- a/Px.Utils/Validation/ContentValidation/ContentValidator.UtilityMethods.cs +++ b/Px.Utils/Validation/ContentValidation/ContentValidator.UtilityMethods.cs @@ -44,11 +44,10 @@ private static Dictionary, string[]> FindDimensionV valuesEntry.Value, syntaxConf.Symbols.Value.ListSeparator, syntaxConf.Symbols.Value.StringDelimeter); - values = CleanListOfStrings(values, syntaxConf); variableValues.Add( new KeyValuePair ( language, dimension ), - [..values] + [.. values.Select(v => SyntaxValidationUtilityMethods.CleanString(v, syntaxConf))] ); } else @@ -241,22 +240,6 @@ private static ValidationFeedback ProcessDimension( return feedbackItems; } - /// - /// Cleans a list of strings from new line characters and quotation marks. - /// - /// The input array of strings to clean - /// object. - /// A list of strings that are the input strings cleaned from new line characters and quotation marks - internal static List CleanListOfStrings(List input, PxFileSyntaxConf syntaxConf) - { - List cleaned = []; - foreach (string item in input) - { - cleaned.Add(SyntaxValidationUtilityMethods.CleanString(item, syntaxConf)); - } - return cleaned; - } - private static Dictionary GetDimensionNames( ValidationStructuredEntry[] entries, string defaultLanguage, @@ -267,8 +250,7 @@ private static Dictionary GetDimensionNames( { string language = entry.Key.Language ?? defaultLanguage; List names = SyntaxValidationUtilityMethods.GetListItemsFromString(entry.Value, syntaxConf.Symbols.Value.ListSeparator, syntaxConf.Symbols.Value.StringDelimeter); - names = CleanListOfStrings(names, syntaxConf); - dimensionNames.Add(language, [.. names]); + dimensionNames.Add(language, [.. names.Select(n => SyntaxValidationUtilityMethods.CleanString(n, syntaxConf))]); } return dimensionNames; } diff --git a/Px.Utils/Validation/ContentValidation/ContentValidator.ValidationFunctions.cs b/Px.Utils/Validation/ContentValidation/ContentValidator.ValidationFunctions.cs index 9b31682..8b7dd60 100644 --- a/Px.Utils/Validation/ContentValidation/ContentValidator.ValidationFunctions.cs +++ b/Px.Utils/Validation/ContentValidation/ContentValidator.ValidationFunctions.cs @@ -116,8 +116,7 @@ public sealed partial class ContentValidator if (availableLanguageEntries.Length == 1) { List languages = availableLanguageEntries[0].Value.Split(validator.SyntaxConf.Symbols.Value.ListSeparator).ToList(); - languages = CleanListOfStrings(languages, validator.SyntaxConf); - validator._availableLanguages = [..languages]; + validator._availableLanguages = [.. languages.Select(lang => SyntaxValidationUtilityMethods.CleanString(lang, validator.SyntaxConf))]; return null; } else