Assuming that
consoleColors
item are of type
ConsoleColorType
, something like that could be used:
public void AddForegroundColor(ColoredConsoleTarget coloredConsoleTarget)
{
var consoleColors = _loggerModel.console_color;
var colorTypes = new ConsoleColorType[]
{
consoleColors.TRACE,
consoleColors.INFO,
consoleColors.DEBUG,
consoleColors.WARN,
consoleColors.ERROR,
consoleColors.FATAL,
};
var consoleOutputColorList = new List<consoleoutputcolor>();
foreach (var item in colorTypes)
{
ConsoleOutputColor traceColor;
ConsoleOutputColor.TryParse(item, true, out traceColor);
consoleOutputColorList.Add(traceColor);
}
AddConsoleRowHighlightingRule(coloredConsoleTarget, consoleOutputColorList);
}
Make any necessary adjustment depending on color types.
Update: Since strings are used, the following line
var colorTypes = new ConsoleColorType[]
should be change for
var colorTypes = new string[]