Esempio n. 1
0
 /// <summary>
 /// Groups the projected elements of an option by a selected key.
 /// </summary>
 /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
 /// <typeparam name="TKey">The type of the key used to group elements.</typeparam>
 /// <typeparam name="TElement">
 /// The type of the transformed elements to include in the grouping.
 /// </typeparam>
 /// <param name="source">A source option.</param>
 /// <param name="keySelector">
 /// A function to select the key that corresponds to an element of <paramref name="source"/>.
 /// </param>
 /// <param name="elementSelector">
 /// A function to transform an element of <paramref name="source"/> to an element to include
 /// in a grouping.
 /// </param>
 /// <returns>
 /// An option that contains a grouping for the projected element of <paramref
 /// name="source"/>, if <paramref name="source"/> is full; otherwise, an empty option.
 /// </returns>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="source"/>, <paramref name="keySelector"/>, or <paramref
 /// name="elementSelector"/> is <see langword="null"/>.
 /// </exception>
 public static IOpt <IOptGrouping <TKey, TElement> > GroupBy <TSource, TKey, TElement>(this IOpt <TSource> source, Func <TSource, TKey> keySelector, Func <TSource, TElement> elementSelector) => source.GroupBy(keySelector, elementSelector, null);
Esempio n. 2
0
 /// <summary>
 /// Groups the projected elements of an option by a selected key.
 /// </summary>
 /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
 /// <typeparam name="TKey">The type of the key used to group elements.</typeparam>
 /// <typeparam name="TElement">
 /// The type of the transformed elements to include in the grouping.
 /// </typeparam>
 /// <param name="source">A source option.</param>
 /// <param name="keySelector">
 /// A function to select the key that corresponds to an element of <paramref name="source"/>.
 /// </param>
 /// <param name="elementSelector">
 /// A function to transform an element of <paramref name="source"/> to an element to include
 /// in a grouping.
 /// </param>
 /// <param name="comparer">
 /// A comparer to determine whether keys are equal. (This parameter is ignored.)
 /// </param>
 /// <returns>
 /// An option that contains a grouping for the projected element of <paramref
 /// name="source"/>, if <paramref name="source"/> is full; otherwise, an empty option.
 /// </returns>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="source"/>, <paramref name="keySelector"/>, or <paramref
 /// name="elementSelector"/> is <see langword="null"/>.
 /// </exception>
 public static IOpt <IOptGrouping <TKey, TElement> > GroupBy <TSource, TKey, TElement>(this IOpt <TSource> source, Func <TSource, TKey> keySelector, Func <TSource, TElement> elementSelector, IEqualityComparer <TKey> comparer) => source.GroupBy(keySelector, elementSelector, GetGrouping);
Esempio n. 3
0
 /// <summary>
 /// Groups the projected elements of an option by a selected key, then applies a transform to
 /// each grouping.
 /// </summary>
 /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
 /// <typeparam name="TKey">The type of the key used to group elements.</typeparam>
 /// <typeparam name="TElement">
 /// The type of the transformed elements to include in the grouping.
 /// </typeparam>
 /// <typeparam name="TResult">The type of the result value for each grouping.</typeparam>
 /// <param name="source">A source option.</param>
 /// <param name="keySelector">
 /// A function to select the key that corresponds to an element of <paramref name="source"/>.
 /// </param>
 /// <param name="elementSelector">
 /// A function to transform an element of <paramref name="source"/> to an element to include
 /// in a grouping.
 /// </param>
 /// <param name="resultSelector">A function to select a result value for each grouping.</param>
 /// <returns>
 /// An option that contains the result of applying <paramref name="resultSelector"/> to the
 /// grouping for the projected element of <paramref name="source"/>, if <paramref
 /// name="source"/> is full; otherwise, an empty option.
 /// </returns>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="source"/>, <paramref name="keySelector"/>, <paramref
 /// name="elementSelector"/>, or <paramref name="resultSelector"/> is <see langword="null"/>.
 /// </exception>
 public static IOpt <TResult> GroupBy <TSource, TKey, TElement, TResult>(this IOpt <TSource> source, Func <TSource, TKey> keySelector, Func <TSource, TElement> elementSelector, Func <TKey, IOpt <TElement>, TResult> resultSelector) => source.GroupBy(keySelector, elementSelector, resultSelector, null);