Example #1
0
        /// <summary>
        /// Will create Reactive of new type.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="source"></param>
        /// <param name="getValue"></param>
        /// <param name="setValue"></param>
        /// <param name="additionalNotifiers"></param>
        /// <returns></returns>
        public static Reactive <TResult> To <T, TResult>(
            this Reactive <T> source,
            Func <Reactive <T>, TResult> getValue,
            Action <Reactive <T>, TResult> setValue,
            params INotifyPropertyChanged[] additionalNotifiers)
        {
            var sources = new INotifyPropertyChanged[] { source };

            if (additionalNotifiers.Length != 0)
            {
                sources = sources.Concat(additionalNotifiers).ToArray();
            }

            return(Of(
                       () => getValue(source),
                       value => setValue(source, value),
                       sources));
        }