public void Write()
        {
            Stream        stream        = StringToMemoryStreamBuilder.Builder(Encoding.UTF8).WriteLine("line1").WriteLine("line2").WriteLine("line3").Done();
            VisitingLines visitor       = new VisitingLines();
            StreamToLines streamToLines = new StreamToLines(visitor, Encoding.UTF8);

            streamToLines.ReadFrom(stream);
            visitor.NoEmptyLines().Lines(3).Line(0, "line1").Line(1, "line2").Line(2, "line3");
        }
Пример #2
0
        public void ReadStream()
        {
            Stream stream = StringToMemoryStreamBuilder.Builder(Encoding.UTF8).WriteLine("line1").WriteLine("line2").Done();

            Console.WriteLine("uncompressed stream length= " + stream.Length);
            var memoryStream = new MemoryStream();
            var gZipStream   = new GZipStream(memoryStream, CompressionMode.Compress);

            stream.CopyTo(gZipStream);
            gZipStream.Flush();
            memoryStream.Position = 0;
            Console.WriteLine("compressed stream length= " + memoryStream.Length);
            var visitingLines = new VisitingLines();
            var compressed    = new MemoryStream(memoryStream.ToArray());

            Console.WriteLine("(copied) compressed stream length= " + compressed.Length);
            new GZipStreamToLines(visitingLines, Encoding.UTF8).ReadFrom(memoryStream);
            visitingLines.NoEmptyLines().Lines(2).Line(0, "line1").Line(1, "line2");
        }
Пример #3
0
 public Stream FromString(string value)
 {
     return(StringToMemoryStreamBuilder.Builder(encoding).WriteLine(value).Done());
 }