Exemple #1
0
        internal int Read(byte[] buffer)
        {
            if (Length - buffer.Length <= CriticalLength)
            {
                if (innerStream == null)
                {
                    if (DataRequest != null)
                    {
                        DataRequest(this, null);
                    }
                }
                else
                {
                    int minimumLength = CriticalLength - (int)Length + buffer.Length;

                    byte[] data            = new byte[minimumLength];
                    int    availableLength = innerStream.Read(data, 0, minimumLength);
                    queue.Write(data, 0, availableLength);
                }
            }

            int available = queue.Read(buffer, 0, buffer.Length);

            readByte += buffer.Length;

            return(available);
        }
 internal void Write(byte[] buffer)
 {
     if (innerStream == null)
     {
         queue.Write(buffer, 0, buffer.Length);
         DataReady(this, null);
     }
     else
     {
         innerStream.Write(buffer, 0, buffer.Length);
         readByte += buffer.Length;
     }
 }