Ejemplo n.º 1
0
        /// <summary>
        /// Creates a subscription to the source, where in every occurrence of the source stream, it transforms the input
        /// item using the <paramref name="selector"/> and pushes the result to the <paramref name="observer"/>.
        /// </summary>
        /// <param name="source">The original source stream.</param>
        /// <param name="observer">The observer of the output stream.</param>
        /// <param name="selector">The conversion delegate to convert from the original type to the destination.</param>
        /// <typeparam name="Tin">The type of the original source stream.</typeparam>
        /// <typeparam name="Tout">The type of the observer and output stream.</typeparam>
        /// <returns>Returns a subscription token used to unsubscribe to the original source.</returns>
        /// <remarks>This method is behaviorally equivalent to doing the following using Rx: source.Select(selector).Subscribe(observer).</remarks>
        public static IDisposable CreateSubscription <Tin, Tout>(this IObservable <Tin> source, IObserver <Tout> observer, Func <Tin, Tout> selector)
            where Tin : class
        {
            var projection = new Projection <Tin, Tout>(observer, selector);

            return(projection.Connect(source));
        }