Example #1
0
            public int Read(T[] buffer, int offset, int count)
            {
                var totalCopiedItems = 0;

                while (count > 0 && reader != null)
                {
                    var itemsCopied = reader.Read(buffer, offset, count);
                    if (itemsCopied > 0)
                    {
                        count            -= itemsCopied;
                        offset           += itemsCopied;
                        totalCopiedItems += itemsCopied;
                    }
                    else
                    {
                        try{
                            reader.Dispose();
                        }finally{
                            reader = null;
                        }
                        reader = GetNextReader();
                    }
                }
                return(totalCopiedItems);
            }
Example #2
0
 public void Close()
 {
     if (m_inputStream != null)
     {
         m_inputStream.Dispose();
         m_inputStream = null;
     }
 }
Example #3
0
        /// <summary>
        /// Dispose of the Stream Reader and close out the source stream and file connections.
        /// </summary>
        public void Dispose()
        {
            if (_reader != null)
            {
                _reader.Close();
                _reader.Dispose();
            }

            if (_web != null)
            {
                _web.Dispose();
            }
        }
Example #4
0
 /// <summary>
 /// Disposes of the stream
 /// </summary>
 public void Dispose()
 {
     _streamReader.Dispose();
 }
Example #5
0
 public void Dispose()
 {
     FReader.Dispose();
     FReader = null;
 }
Example #6
0
 public void Dispose()
 {
     FDataReader.Dispose();
 }
Example #7
0
 public void Dispose()
 {
     FSourceReader.Dispose();
     FSourceReader = null;
     FRangeStream  = null;
 }
Example #8
0
 public static IOutputStream <TDst> Transform <TSrc, TDst>(this IOutputStream <TSrc> stream, ITransformation <TSrc, TDst> transformation, int readBufSize = 1024)
 {
     //Encoding.UTF8.GetBytes(str, strPos, charsToBuffer, intBuf, 0);
     return(CreateOutput <TDst>(() => {
         var inBuf = new TSrc[readBufSize];
         var inBufPos = 0;
         var inBufCnt = 0;
         IStreamReader <TSrc> reader = null;
         if (stream != null)
         {
             reader = stream.CreateReader();
         }
         return new AnonymousStreamReader <TDst>((buf, ofs, cnt) => {
             var totalBytesCopied = 0;
             while (cnt > 0)
             {
                 var bytesCopied = transformation.Copy(buf, ofs, cnt);
                 if (bytesCopied > 0)
                 {
                     ofs += bytesCopied;
                     cnt -= bytesCopied;
                     totalBytesCopied += bytesCopied;
                 }
                 else
                 {
                     Action process = () => {
                         var itemsProcessed = transformation.Process(inBuf, inBufPos, inBufCnt);
                         inBufCnt -= itemsProcessed;
                         inBufPos += itemsProcessed;
                     };
                     if (inBufCnt > 0)
                     {
                         process();
                     }
                     else
                     {
                         if (reader == null)
                         {
                             return totalBytesCopied;
                         }
                         inBufPos = 0;
                         //try {
                         inBufCnt = reader.Read(inBuf, 0, inBuf.Length);
                         //} catch (Exception err) {
                         //inBufCnt = 0;
                         //try {
                         //    reader.Dispose();
                         //} finally {
                         //    reader = null;
                         //}
                         //}
                         if (inBufCnt > 0)
                         {
                             process();
                         }
                         else
                         {
                             try {
                                 reader.Dispose();
                             } finally {
                                 reader = null;
                             }
                             return totalBytesCopied;
                         }
                     }
                 }
             }
             return totalBytesCopied;
         });
     }));
 }
Example #9
0
 public void Dispose()
 {
     m_stream.Dispose();
     m_stream  = null;
     m_current = null;
 }