/// <summary> /// Creates an observable sequence by reading to the end of the specified <paramref name="reader"/> each time /// the <paramref name="textAvailable"/> sequence notifies that additional text is available to be read /// and advances the position within the reader to the end of the stream. /// </summary> /// <typeparam name="TOther">The type of elements in the sequence that notifies when text is available to be read.</typeparam> /// <param name="reader">The object from which text is read as it becomes available.</param> /// <param name="textAvailable">An observable sequence that notifies when additional text is available to be read.</param> /// <remarks> /// The generated sequence is intended to match the underlying stream; however, this behavior /// depends on whether the reader is well-behaved and whether the reader is not being shared. Reading always starts from the /// current position of the reader in the underlying stream. The reader is expected to increment its position in the stream /// when it's read. Each time that the <paramref name="textAvailable"/> sequence notifies that additional text is available, /// reading is expected to begin at the previous position in the stream, but if the reader is shared or it's not well-behaved, /// then the generated sequence may contain unexpected data. /// </remarks> /// <returns>An observable sequence of strings read from the specified <paramref name="reader"/>.</returns> public static IObservable <string> ToObservable <TOther>(this TextReader reader, IObservable <TOther> textAvailable) { Contract.Requires(reader != null); Contract.Requires(textAvailable != null); Contract.Ensures(Contract.Result <IObservable <string> >() != null); return(reader.ToObservable(textAvailable, Scheduler.CurrentThread)); }