Changes between Version 9 and Version 10 of ICryptoolStreamUsage


Ignore:
Timestamp:
Feb 12, 2011, 1:29:07 AM (11 years ago)
Author:
Matthäus Wander
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ICryptoolStreamUsage

    v9 v10  
    2121[[Image(source:/trunk/Documentation/ArchitectureAndDesign/CStream/CStreamWriter.png)]]
    2222
    23  * Create an output property (e.g. called "OutputStream") with type ICryptoolStream
    24  * In Execute() create a new CStreamWriter
    25  * Set the CStreamWriter as OutputStream property (will be implicitly downcasted)
    26  * Announce the OutputStream update with OnPropertyChanged("OutputStream")
    27  * Pass data to the stream via CStreamWriter.Write()
    28  * Call CStreamWriter.Close() when finished
    29  * Best practice is to not care about disposal of writer
     23 * Create an output property (e.g. called "OutputStream") with type ICryptoolStream.
     24 * In Execute() create a new CStreamWriter.
     25 * Set the CStreamWriter as OutputStream property (will be implicitly downcasted).
     26 * Announce the OutputStream update with OnPropertyChanged("OutputStream").
     27 * Pass data to the stream via CStreamWriter.Write().
     28 * Call CStreamWriter.Close() when finished.
     29 * Best practice is to not care about disposal of writer.
    3030
    3131{{{
     
    5959[[Image(source:/trunk/Documentation/ArchitectureAndDesign/CStream/CStreamReader.png)]]
    6060
    61  * Create an input property (e.g. called "InputStream") with type ICryptoolStream
    62  * In Execute() call CreateReader() on that ICryptoolStream to get a new CStreamReader
    63  * Retrieve data with CStreamReader.Read() ''in a loop''
    64  * End loop when read attempt returns 0 bytes
     61 * Create an input property (e.g. called "InputStream") with type ICryptoolStream.
     62 * In Execute() call CreateReader() on that ICryptoolStream to get a new CStreamReader.
     63 * Retrieve data with CStreamReader.Read() ''in a loop''.
     64 * End loop when read attempt returns 0 bytes.
     65 * Beware of evaluating CStreamReader.Length: writer may not have finished writing to the stream, so the length may grow.
    6566 * Best practice is to Dispose() the CStreamReader afterwards.
    6667
     
    9192}
    9293}}}
     94
     95== Hints for implementing lazy readers ==
     96
     97 * You may use CStreamReader.WaitEof() to wait until the writer has finished. After that, length will remain constant and you can expect CStreamReader.Length to remain constant.
     98 * If you don't like the property of CStreamReader.Read(byte[]), that it may return less bytes than requested, you can use CStreamReader.ReadFully(byte[]). Still, when you reach the end of a closed stream it will return less bytes.
     99 * If you're superlazy, CStreamReader.ReadFully() will do all the stream reading and waiting work and deliver everything as a single byte[]. ReadFully() without parameters is terribly inefficient and you may become memory problems when processing large data amounts. Try to avoid it.