Example #1
0
        /// <summary>
        /// Matches all results from the specified <paramref name="parser"/> that equal the specified
        /// <paramref name="value"/>.
        /// </summary>
        /// <typeparam name="TSource">The type of the source elements.</typeparam>
        /// <typeparam name="TResult">The type of the elements that are generated from parsing the source elements.</typeparam>
        /// <param name="parser">The parser from which matches equivalent to the specified <paramref name="value"/> will be yielded.</param>
        /// <param name="value">The value to be compared to matches for equality.</param>
        /// <returns>A parser that matches only those results from the specified <paramref name="parser"/> that equal
        /// the specified <paramref name="value"/>.</returns>
        public static IObservableParser <TSource, TResult> Of <TSource, TResult>(
            this IObservableParser <TSource, TResult> parser,
            TResult value)
        {
            Contract.Requires(parser != null);
            Contract.Ensures(Contract.Result <IObservableParser <TSource, TResult> >() != null);

            return(parser.Of(value, EqualityComparer <TResult> .Default));
        }