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

74 lines
1.6 KiB
C#
Raw Normal View History

2023-02-16 12:57:06 +00:00
namespace InnovEnergy.SysTools.Utils;
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;
}
}