Files
TextParser/TextParser/Data/DataConversionHelpers.cs
Simon Diesenreiter 414c74be84
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after 25s
CI / tests_linux (9.0.X, ubuntu-latest) (push) Failing after 4m2s
feat: add two dimensional data walker, refs: NOISSUE
2025-10-26 19:07:37 +01:00

37 lines
1.1 KiB
C#

namespace Parsing.Data;
using Parsing;
using Parsing.Tokenization;
public static class DataConversionHelpers
{
public static List<TNewType> ConvertData<TNewType, TOldType>(this List<TOldType> valueList, Func<TOldType, TNewType> converter)
{
var newList = new List<TNewType>();
foreach (var value in valueList)
{
newList.Add(converter(value));
}
return newList;
}
public static List<TNewType> ConvertData<TNewType, TOldType>(this List<TOldType> valueList, Func<TOldType, List<TNewType>> converter)
{
var newList = new List<TNewType>();
foreach (var value in valueList)
{
newList.AddRange(converter(value));
}
return newList;
}
public static List<List<TNewType>> ConvertData<TNewType, TOldType>(this List<List<TOldType>> valueListList, Func<TOldType, TNewType> converter)
{
var newListList = new List<List<TNewType>>();
foreach (var valueList in valueListList)
{
newListList.Add(valueList.ConvertData<TNewType, TOldType>(converter));
}
return newListList;
}
}