2021-06-19 18:02:33 +02:00
|
|
|
using System.Collections.Generic;
|
2021-05-31 13:55:54 +02:00
|
|
|
using System.Text;
|
|
|
|
|
2021-06-19 18:02:33 +02:00
|
|
|
namespace Jellyfin.Extensions
|
2021-05-31 13:55:54 +02:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Extension methods for the <see cref="StringBuilder"/> class.
|
|
|
|
/// </summary>
|
|
|
|
public static class StringBuilderExtensions
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Concatenates and appends the members of a collection in single quotes using the specified delimiter.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="builder">The string builder.</param>
|
|
|
|
/// <param name="delimiter">The character delimiter.</param>
|
|
|
|
/// <param name="values">The collection of strings to concatenate.</param>
|
|
|
|
/// <returns>The updated string builder.</returns>
|
|
|
|
public static StringBuilder AppendJoinInSingleQuotes(this StringBuilder builder, char delimiter, IReadOnlyList<string> values)
|
|
|
|
{
|
2021-06-05 20:16:04 +02:00
|
|
|
var len = values.Count;
|
|
|
|
for (var i = 0; i < len; i++)
|
2021-05-31 13:55:54 +02:00
|
|
|
{
|
|
|
|
builder.Append('\'')
|
|
|
|
.Append(values[i])
|
|
|
|
.Append('\'')
|
|
|
|
.Append(delimiter);
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove last ,
|
|
|
|
builder.Length--;
|
|
|
|
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|