示例#1
0
        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());
        }
示例#2
0
        public static string[] OneToMany(string value, ListFormat listFormat)
        {
            if (value == "")
            {
                return(Array.Empty <string>());
            }
            var parser = listFormat.CreateParser(value, StringBuilderEx.Acquire());
            var buffer = MemoryBuffer <string> .Lease(true);

            try {
                while (parser.TryParseNext())
                {
                    buffer.Add(parser.Item);
                }
                return(buffer.ToArray());
            }
            finally {
                buffer.Release();
                parser.ItemBuilder.Release();
            }
        }