using System.Text;
namespace Dpz.Core.Service.ObjectStorage.VideoHandle;
/// <summary>
/// 视频处理参数
/// </summary>
public class AvOpts : List<OptionType>
{
private const int MaxCount = 10;
public AvOpts() { }
public AvOpts(ICollection<OptionType> items)
{
AddRange(items);
}
public new void Add(OptionType item)
{
if (Count >= MaxCount)
{
throw new InvalidOperationException("The maximum number of items has been reached.");
}
base.Add(item);
}
public new void AddRange(ICollection<OptionType> items)
{
var c = Math.Max(MaxCount - Count, 0);
if (c > 0)
{
base.AddRange(items.Take(c));
}
}
public override string ToString()
{
var sb = new StringBuilder();
foreach (var item in this)
{
var value = item.Value switch
{
bool bv => bv.ToString().ToLower(),
null => "",
_ => item.Value.ToString()
};
sb.Append($"/{item.Name}/{value}");
}
return sb.ToString();
}
}