Skip to content

Commit

Permalink
Removes utility method with a linq function
Browse files Browse the repository at this point in the history
  • Loading branch information
sakari-malkki committed Sep 13, 2024
1 parent 235813e commit 3630901
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ private static Dictionary<KeyValuePair<string, string>, string[]> FindDimensionV
valuesEntry.Value,
syntaxConf.Symbols.Value.ListSeparator,
syntaxConf.Symbols.Value.StringDelimeter);
values = CleanListOfStrings(values, syntaxConf);

variableValues.Add(
new KeyValuePair<string, string> ( language, dimension ),
[..values]
[.. values.Select(v => SyntaxValidationUtilityMethods.CleanString(v, syntaxConf))]
);
}
else
Expand Down Expand Up @@ -241,22 +240,6 @@ private static ValidationFeedback ProcessDimension(
return feedbackItems;
}

/// <summary>
/// Cleans a list of strings from new line characters and quotation marks.
/// </summary>
/// <param name="input">The input array of strings to clean</param>
/// <param name="syntaxConf>The syntax configuration for the PX file. The syntax configuration is represented by a <see cref="PxFileSyntaxConf"/> object.</param>
/// <returns>A list of strings that are the input strings cleaned from new line characters and quotation marks</returns>
internal static List<string> CleanListOfStrings(List<string> input, PxFileSyntaxConf syntaxConf)
{
List<string> cleaned = [];
foreach (string item in input)
{
cleaned.Add(SyntaxValidationUtilityMethods.CleanString(item, syntaxConf));
}
return cleaned;
}

private static Dictionary<string, string[]> GetDimensionNames(
ValidationStructuredEntry[] entries,
string defaultLanguage,
Expand All @@ -267,8 +250,7 @@ private static Dictionary<string, string[]> GetDimensionNames(
{
string language = entry.Key.Language ?? defaultLanguage;
List<string> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ public sealed partial class ContentValidator
if (availableLanguageEntries.Length == 1)
{
List<string> 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
Expand Down

0 comments on commit 3630901

Please sign in to comment.