mirror of
https://github.com/BeyondDimension/SteamTools.git
synced 2026-10-23 18:38:04 +08:00
V1.2 新构架
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
namespace System.Text
|
||||
{
|
||||
public static class StringBuilderExtensions
|
||||
{
|
||||
internal static void AppendFormatLine(
|
||||
Action<string, object?[]> appendFormat,
|
||||
Action appendLine,
|
||||
string format,
|
||||
params object?[] args)
|
||||
{
|
||||
appendFormat(format, args);
|
||||
appendLine();
|
||||
}
|
||||
|
||||
internal static void AppendDateTimeNowLine(Action<string, object?[]> appendFormatLine, DateTime? now = null)
|
||||
{
|
||||
now ??= DateTime.Now;
|
||||
AppendFormatLine("当前时间:{0}", now.Value.ToString(DateTimeFormat.Complete));
|
||||
void AppendFormatLine(string format, params object[] args) => appendFormatLine(format, args);
|
||||
}
|
||||
|
||||
public static StringBuilder AppendFormatLine(this StringBuilder sb, string format, params object?[] args)
|
||||
{
|
||||
AppendFormatLine((f, a) => sb.AppendFormat(f, a), () => sb.AppendLine(), format, args);
|
||||
return sb;
|
||||
}
|
||||
|
||||
public static StringBuilder AppendDateTimeNowLine(this StringBuilder sb, DateTime? now = null)
|
||||
{
|
||||
AppendDateTimeNowLine((format, args) => sb.AppendFormatLine(format, args), now);
|
||||
return sb;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user