Пример #1
0
        public static Writer Make(int index, NameWriter name)
        {
            return((reader, buffer) =>
            {
                if (reader.IsDBNull(index))
                {
                    return buffer;
                }

                Comma.Write(ref buffer);
                name.Write(ref buffer);

                if (reader.GetBoolean(index))
                {
                    TrueString.CopyTo(buffer);
                    buffer = buffer.Slice(4);
                }
                else
                {
                    FalseString.CopyTo(buffer);
                    buffer = buffer.Slice(5);
                }

                return buffer;
            });
        }
Пример #2
0
        public static Writer Make(int index, NameWriter name)
        {
            return((reader, buffer, pos) =>
            {
                if (reader.IsDBNull(index))
                {
                    return pos;
                }

                Comma.Write(buffer, ref pos);
                name.Write(buffer, ref pos);

                if (reader.GetBoolean(index))
                {
                    TrueString.CopyTo(buffer.Slice(pos, 4));
                    pos += 4;
                }
                else
                {
                    FalseString.CopyTo(buffer.Slice(pos, 5));
                    pos += 5;
                }

                return pos;
            });
        }
Пример #3
0
        public static Writer Make(int index, NameWriter name)
        {
            return((reader, buffer) =>
            {
                if (reader.IsDBNull(index))
                {
                    return buffer;
                }

                Comma.Write(ref buffer);
                name.Write(ref buffer);

                Utf8Formatter.TryFormat(reader.GetByte(index), buffer, out var n);
                return buffer.Slice(n);
            });
        }
Пример #4
0
        public static Writer Make(int index, NameWriter name)
        {
            return((reader, buffer, pos) =>
            {
                if (reader.IsDBNull(index))
                {
                    return pos;
                }

                Comma.Write(buffer, ref pos);
                name.Write(buffer, ref pos);

                Utf8Formatter.TryFormat(reader.GetByte(index), buffer.Slice(pos, 32), out var n);
                return pos + n;
            });
        }
Пример #5
0
        public static Writer Make(int index, NameWriter name)
        {
            return((reader, buffer, pos) =>
            {
                if (reader.IsDBNull(index))
                {
                    return pos;
                }

                Comma.Write(buffer, ref pos);
                name.Write(buffer, ref pos);

                buffer[pos++] = QuotationMark;
                Utf8Formatter.TryFormat(reader.GetFieldValue <TimeSpan>(index), buffer.Slice(pos, 32), out var n, new StandardFormat('g'));
                pos = pos + n;
                buffer[pos] = QuotationMark;
                return pos + 1;
            });
        }
Пример #6
0
        public static Writer Make(int index, NameWriter name)
        {
            return((reader, buffer) =>
            {
                if (reader.IsDBNull(index))
                {
                    return buffer;
                }

                Comma.Write(ref buffer);
                name.Write(ref buffer);

                buffer[0] = QuotationMark;
                buffer = buffer.Slice(1);
                Utf8Formatter.TryFormat(reader.GetFieldValue <Guid>(index), buffer, out var n, new StandardFormat('O'));
                buffer[n] = QuotationMark;
                return buffer.Slice(n + 1);
            });
        }
Пример #7
0
        public static Writer Make(int index, NameWriter name)
        {
            return((reader, buffer, pos) =>
            {
                if (reader.IsDBNull(index))
                {
                    return pos;
                }

                Comma.Write(buffer, ref pos);
                name.Write(buffer, ref pos);

                var chars = ArrayPool <char> .Shared.Rent(1024);

                try
                {
                    int charCount = (int)reader.GetChars(index, 0, chars, 1, 1000);
                    if (charCount == 0)
                    {
                        EmptyString.CopyTo(buffer.Slice(pos, 2));
                        return pos + 2;
                    }

                    chars[0] = '"';
                    chars[charCount + 1] = '"';
                    charCount += 2;
                    var source = new ReadOnlySpan <char>(chars, 0, charCount);
                    var target = buffer.Slice(pos);
                    var byteCount = Encoding.UTF8.GetBytes(source, target);
                    return pos + byteCount;
                }
                finally
                {
                    ArrayPool <char> .Shared.Return(chars);
                }
            });
        }