Ejemplo n.º 1
0
        /// <summary>
        /// Notifies the property to update the value, for each element.
        /// </summary>
        /// <typeparam name="TSource">The type of the source.</typeparam>
        /// <typeparam name="TProperty">The type of the property.</typeparam>
        /// <param name="source">The source sequence of elements.</param>
        /// <param name="property">The get-only property.</param>
        /// <returns>An <see cref="IDisposable"/> object used to unsubscribe from the source sequence.</returns>
        public static IDisposable Subscribe <TSource, TProperty>(this IObservable <TSource> source, IGetOnlyProperty <TProperty> property)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            return(source.Subscribe(o => property.OnNext()));
        }