FFMpegCore/FFMpegCore/Extend/KeyValuePairExtensions.cs
Malte Rosenbjerg 390cd00005 Minor fixes
Former-commit-id: 1b67ea76f0
2021-10-21 19:43:13 +02:00

24 lines
No EOL
857 B
C#

using System.Collections.Generic;
namespace FFMpegCore.Extend
{
internal static class KeyValuePairExtensions
{
/// <summary>
/// Concat the two members of a <see cref="KeyValuePair{TKey,TValue}" />
/// </summary>
/// <param name="pair">Input object</param>
/// <param name="enclose">
/// If true encloses the value part between quotes if contains an space character. If false use the
/// value unmodified
/// </param>
/// <returns>The formatted string</returns>
public static string FormatArgumentPair(this KeyValuePair<string, string> pair, bool enclose)
{
var key = pair.Key;
var value = enclose ? StringExtensions.EncloseIfContainsSpace(pair.Value) : pair.Value;
return $"{key}={value}";
}
}
}