37 lines
1.1 KiB
C#
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;
|
|
}
|
|
} |