Innovenergy_trunk/csharp/Lib/SysTools/Utils/ConsoleUtils.cs

74 lines
1.6 KiB
C#
Raw Normal View History

namespace InnovEnergy.Lib.SysTools.Utils;
2023-02-16 12:57:06 +00:00
internal static class ConsoleUtils
{
public static T WriteLine<T>(this T t, ConsoleColor color)
{
var c = Console.ForegroundColor;
Console.ForegroundColor = color;
Console.WriteLine(t);
Console.ForegroundColor = c;
return t;
}
public static T WriteLine<T>(this T t)
{
Console.WriteLine(t);
return t;
}
public static T WriteLine<T>(this T t, ConsoleColor color, params String[] more)
{
var c = Console.ForegroundColor;
Console.ForegroundColor = color;
Console.WriteLine(t + " " + more.JoinWith(" "));
Console.ForegroundColor = c;
return t;
}
public static T WriteLine<T>(this T t, params String[] more)
{
Console.WriteLine(t + " " + more.JoinWith(" "));
return t;
}
public static T Write<T>(this T t, ConsoleColor color)
{
var c = Console.ForegroundColor;
Console.ForegroundColor = color;
Console.Write(t);
Console.ForegroundColor = c;
return t;
}
public static T Write<T>(this T t)
{
Console.Write(t);
return t;
}
public static T Write<T>(this T t, ConsoleColor color, params String[] more)
{
var c = Console.ForegroundColor;
Console.ForegroundColor = color;
Console.Write(t + " " + more.JoinWith(" "));
Console.ForegroundColor = c;
return t;
}
public static T Write<T>(this T t, params String[] more)
{
Console.Write(t + " " + more.JoinWith(" "));
return t;
}
}