internal ListFormatter(ListFormat format, StringBuilder outputBuilder, int itemIndex) { Delimiter = format.Delimiter; Escape = format.Escape; NoItems = format.NoItems; OutputBuilder = outputBuilder; ItemIndex = itemIndex; }
public SymbolListFormatter(char delimiter, char escape = '\\') { DelimiterChar = delimiter; EscapeChar = escape; Delimiter = delimiter.ToString(); Escape = escape.ToString(); EscapedDelimiter = $"{Escape}{Delimiter}"; EscapedEscape = $"{Escape}{Escape}"; ListFormat = new ListFormat(delimiter, escape); }
public static string ManyToOne(IEnumerable <string> values, ListFormat listFormat) { using var f = listFormat.CreateFormatter(); foreach (var value in values) { f.Append(value); } f.AppendEnd(); return(f.OutputBuilder.ToString()); }
public static string ManyToOne(IEnumerable <string> values, ListFormat listFormat) { var formatter = listFormat.CreateFormatter(StringBuilderEx.Acquire()); foreach (var value in values) { formatter.Append(value); } formatter.AppendEnd(); return(formatter.OutputBuilder.ToStringAndRelease()); }
public static string[] OneToMany(string value, ListFormat listFormat) { if (value == "") { return(Array.Empty <string>()); } using var p = listFormat.CreateParser(value); var buffer = MemoryBuffer <string> .Lease(true); try { while (p.TryParseNext()) { buffer.Add(p.Item); } return(buffer.ToArray()); } finally { buffer.Release(); } }