Revenj.Utility.ChunkedMemoryStream.ToPostgresBytea C# (CSharp) Method

ToPostgresBytea() public method

Convert stream to Postgres representation of bytea
public ToPostgresBytea ( TextWriter sw ) : void
sw System.IO.TextWriter
return void
        public void ToPostgresBytea(TextWriter sw)
        {
            var total = TotalSize >> BlockShift;
            var remaining = TotalSize & BlockAnd;
            byte[] block;
            for (int i = 0; i < total; i++)
            {
                block = Blocks[i];
                for (int j = 0; j < block.Length; j++)
                {
                    var b = block[j];
                    sw.Write(CharMap[b >> 4]);
                    sw.Write(CharMap[b & 0xf]);
                }
            }
            block = Blocks[total];
            for (int j = 0; j < remaining; j++)
            {
                var b = block[j];
                sw.Write(CharMap[b >> 4]);
                sw.Write(CharMap[b & 0xf]);
            }
        }