mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-02 16:19:12 +00:00
21 lines
684 B
C#
21 lines
684 B
C#
using System.Text;
|
|
|
|
namespace DiscordChatExporter.Domain.Internal
|
|
{
|
|
internal static class StringExtensions
|
|
{
|
|
public static StringBuilder AppendLineIfNotNullOrWhiteSpace(this StringBuilder builder, string? value) =>
|
|
!string.IsNullOrWhiteSpace(value) ? builder.AppendLine(value) : builder;
|
|
|
|
public static StringBuilder Trim(this StringBuilder builder)
|
|
{
|
|
while (builder.Length > 0 && char.IsWhiteSpace(builder[0]))
|
|
builder.Remove(0, 1);
|
|
|
|
while (builder.Length > 0 && char.IsWhiteSpace(builder[^1]))
|
|
builder.Remove(builder.Length - 1, 1);
|
|
|
|
return builder;
|
|
}
|
|
}
|
|
} |