コード例 #1
0
        public byte[] GetBytes(long index, int count)
        {
            if (index < 0 && count > 0)
            {
                int n = (int)Math.Min(-index, count);
                index += n;
                count -= n;
            }

            if (count == 0)
            {
                return(new byte[0]);
            }

            count = (int)Math.Min(Length - index, count);
            var bytes = new byte[count];
            int i     = 0;

            while (index + i < offset && i < count)
            {
                bytes[i] = Bytes[index + i];
                i++;
            }

            if (i < count)
            {
                var chunk = array.Substring((int)offset / 2, (count - i) / 2);
                var buf   = Encoding.Unicode.GetBytes(chunk);

                for (int j = 0; j < buf.Length; j++)
                {
                    Bytes[offset++] = buf[j];
                }

                while (index + i < offset && i < count)
                {
                    bytes[i] = Bytes[index + i];
                    i++;
                }
            }

            return(bytes);
        }
コード例 #2
0
        bool GetNextStringChunk()
        {
            int      amount = Math.Min(length - offset, CHUNK_SIZE);
            string   chunk  = raw.Substring(offset, amount);
            TextIter iter   = textView.Buffer.EndIter;

            textView.Buffer.Insert(ref iter, chunk);
            offset += amount;

            if (offset < length)
            {
                return(true);
            }

            idle_id = 0;

            // Remove this idle callback
            return(false);
        }