Esempio n. 1
0
        public string ToString(SymbolList source)
        {
            var formatter = ListFormat.CreateFormatter(StringBuilderEx.Acquire());

            foreach (var segment in source.GetSegments())
            {
                formatter.Append(segment.Value);
            }
            formatter.AppendEnd();
            return(formatter.OutputBuilder.ToStringAndRelease());
        }
Esempio n. 2
0
        private async Task <string> NormalizeNameAsync(AppDbContext dbContext, string name, long userId, CancellationToken cancellationToken = default)
        {
            // Normalizing name
            var sb = StringBuilderEx.Acquire();

            foreach (var c in name)
            {
                if (char.IsLetterOrDigit(c) || c == '_' || c == '-')
                {
                    sb.Append(c);
                }
                else if (sb.Length == 0 || char.IsLetterOrDigit(sb[^ 1]))
Esempio n. 3
0
        public SymbolList Parse(string source)
        {
            var parser = ListFormat.CreateParser(source, StringBuilderEx.Acquire());
            var list   = (SymbolList?)null;

            while (parser.TryParseNext())
            {
                list = new SymbolList(list, parser.Item);
            }
            parser.ItemBuilder.Release();
            return(list ?? SymbolList.Empty);
        }
        private static string RemoveAssemblyDetails(string fullyQualifiedTypeName)
        {
            var sb = StringBuilderEx.Acquire(0x20);
            var writingAssemblyName = false;
            var skipping            = false;

            foreach (var c in fullyQualifiedTypeName)
            {
                switch (c)
                {
                case '[':
                case ']':
                    writingAssemblyName = false;
                    skipping            = false;
                    sb.Append(c);
                    break;

                case ',':
                    if (!writingAssemblyName)
                    {
                        writingAssemblyName = true;
                        sb.Append(c);
                    }
                    else
                    {
                        skipping = true;
                    }
                    break;

                default:
                    if (!skipping)
                    {
                        sb.Append(c);
                    }
                    break;
                }
            }
            return(sb.ToStringAndRelease());
        }