Exemplo n.º 1
0
        public static async Task <int> BufferAsync(this HGlobalCache <char> hGCache, TextReader textReader)
        {
            int offset = 0;

Loop:

            if (offset >= hGCache.Count)
            {
                hGCache.Expand(1218);
            }

            IntPtr address;

            unsafe
            {
                address = (IntPtr)(hGCache.GetPointer() + offset);
            }

            int readCount = await ReadCharsAsync(
                textReader,
                address,
                hGCache.Count - offset);

            offset += readCount;

            if (offset == hGCache.Count)
            {
                goto Loop;
            }

            return(offset);
        }
Exemplo n.º 2
0
        public static unsafe int Buffer(this HGlobalCache <char> hGCache, TextReader textReader)
        {
            int offset = 0;

Loop:

            if (offset >= hGCache.Count)
            {
                hGCache.Expand(1218);
            }

            int readCount = ReadChars(
                textReader,
                hGCache.GetPointer() + offset,
                hGCache.Count - offset);

            offset += readCount;

            if (offset == hGCache.Count)
            {
                goto Loop;
            }

            return(offset);
        }
Exemplo n.º 3
0
        private void ReadStringToHGlobal(int bytesLength)
        {
            if (hGlobal.Capacity <= GetUtf8MaxCharsLength(bytesLength))
            {
                hGlobal.Expand(GetUtf8MaxCharsLength(bytesLength));
            }

            hGlobal.Count = GetUtf8Chars(current, bytesLength, hGlobal.GetPointer());

            current += bytesLength;
        }
Exemplo n.º 4
0
        private void InternalExpand(int expandMinSize)
        {
            if (HGCache.Capacity == HGlobalCache <byte> .MaxSize && Stream != null && offset != 0)
            {
                HGCache.Count = offset;

                HGCache.WriteTo(Stream);

                offset = 0;

                Expand(expandMinSize);
            }
            else
            {
                HGCache.Expand(expandMinSize);
            }
        }