/// <summary>
 /// Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. Key values are compared by using a specified comparer, and the elements of each group are projected by using a specified function.
 /// </summary>
 /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
 /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam>
 /// <typeparam name="TElement">The type of the elements in each <see cref="T:System.Linq.IGrouping`2"/>.</typeparam>
 /// <typeparam name="TResult">The type of the result value returned by <paramref name="resultSelector"/>.</typeparam>
 /// <param name="source">An <see cref="IBindableCollection{TElement}"/> whose elements to group.</param>
 /// <param name="keySelector">A function to extract the key for each element.</param>
 /// <param name="elementSelector">A function to map each source element to an element in an <see cref="T:System.Linq.IGrouping`2"/>.</param>
 /// <param name="resultSelector">A function to create a result value from each group.</param>
 /// <param name="comparer">An <see cref="T:System.Collections.Generic.IEqualityComparer`1"/> to compare keys with.</param>
 /// <param name="dependencyAnalysisMode">The dependency analysis mode.</param>
 /// <returns>
 /// A collection of elements of type TResult where each element represents a projection over a group and its key.
 /// </returns>
 public static IBindableCollection <TResult> GroupBy <TSource, TKey, TElement, TResult>(this IBindableCollection <TSource> source, Expression <Func <TSource, TKey> > keySelector, Expression <Func <TSource, TElement> > elementSelector, Expression <Func <TKey, IBindableCollection <TElement>, TResult> > resultSelector, IEqualityComparer <TKey> comparer, DependencyDiscovery dependencyAnalysisMode)
     where TSource : class
     where TElement : class
     where TResult : class
 {
     return(source.GroupBy(keySelector, elementSelector, comparer, dependencyAnalysisMode).Into(resultSelector));
 }
 /// <summary>
 /// Returns distinct elements from a sequence by using a specified <see cref="T:System.Collections.Generic.IEqualityComparer`1"/> to compare values.
 /// </summary>
 /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
 /// <param name="source">The sequence to remove duplicate elements from.</param>
 /// <param name="comparer">An <see cref="T:System.Collections.Generic.IEqualityComparer`1"/> to compare values.</param>
 /// <returns>
 /// An <see cref="IBindableCollection{TElement}"/> that contains distinct elements from the source sequence.
 /// </returns>
 /// <exception cref="T:System.ArgumentNullException">
 ///     <paramref name="source"/> is null.</exception>
 public static IBindableCollection <TSource> Distinct <TSource>(this IBindableCollection <TSource> source, IEqualityComparer <TSource> comparer) where TSource : class
 {
     if (comparer == null)
     {
         comparer = new DefaultComparer <TSource>();
     }
     return(source.GroupBy(c => comparer.GetHashCode(c), DependencyDiscovery.Disabled).Select(group => group.First().Current, DependencyDiscovery.Disabled));
 }
 /// <summary>
 /// Groups the elements of a sequence according to a specified key selector function and compares the keys by using a specified comparer.
 /// </summary>
 /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
 /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam>
 /// <param name="source">An <see cref="IBindableCollection{TElement}"/> whose elements to group.</param>
 /// <param name="keySelector">A function to extract the key for each element.</param>
 /// <param name="comparer">An <see cref="T:System.Collections.Generic.IEqualityComparer`1"/> to compare keys.</param>
 /// <param name="dependencyAnalysisMode">The dependency analysis mode.</param>
 /// <returns>
 /// An IEnumerable&lt;IGrouping&lt;TKey, TSource&gt;&gt; in C# or IEnumerable(Of IGrouping(Of TKey, TSource)) in Visual Basic where each <see cref="T:System.Linq.IGrouping`2"/> object contains a collection of objects and a key.
 /// </returns>
 /// <exception cref="T:System.ArgumentNullException">
 ///     <paramref name="source"/> or <paramref name="keySelector"/> is null.</exception>
 public static IBindableCollection <IBindableGrouping <TKey, TSource> > GroupBy <TSource, TKey>(this IBindableCollection <TSource> source, Expression <Func <TSource, TKey> > keySelector, IEqualityComparer <TKey> comparer, DependencyDiscovery dependencyAnalysisMode) where TSource : class
 {
     return(source.GroupBy(keySelector, s => s, comparer, dependencyAnalysisMode));
 }
 /// <summary>
 /// Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key.
 /// </summary>
 /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
 /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam>
 /// <typeparam name="TResult">The type of the result value returned by <paramref name="resultSelector"/>.</typeparam>
 /// <param name="source">An <see cref="IBindableCollection{TElement}"/> whose elements to group.</param>
 /// <param name="keySelector">A function to extract the key for each element.</param>
 /// <param name="resultSelector">A function to create a result value from each group.</param>
 /// <param name="dependencyAnalysisMode">The dependency analysis mode.</param>
 /// <returns>
 /// A collection of elements of type TResult where each element represents a projection over a group and its key.
 /// </returns>
 public static IBindableCollection <TResult> GroupBy <TSource, TKey, TResult>(this IBindableCollection <TSource> source, Expression <Func <TSource, TKey> > keySelector, Expression <Func <TKey, IBindableCollection <TSource>, TResult> > resultSelector, DependencyDiscovery dependencyAnalysisMode)
     where TSource : class
     where TResult : class
 {
     return(source.GroupBy(keySelector, s => s, new DefaultComparer <TKey>(), dependencyAnalysisMode).Into(resultSelector));
 }
 /// <summary>
 /// Groups the elements of a sequence according to a specified key selector function and projects the elements for each group by using a specified function.
 /// </summary>
 /// <typeparam name="TSource">The type of the elements of <paramref name="source"/>.</typeparam>
 /// <typeparam name="TKey">The type of the key returned by <paramref name="keySelector"/>.</typeparam>
 /// <typeparam name="TElement">The type of the elements in the <see cref="T:System.Linq.IGrouping`2"/>.</typeparam>
 /// <param name="source">An <see cref="IBindableCollection{TElement}"/> whose elements to group.</param>
 /// <param name="keySelector">A function to extract the key for each element.</param>
 /// <param name="elementSelector">A function to map each source element to an element in the <see cref="T:System.Linq.IGrouping`2"/>.</param>
 /// <param name="dependencyAnalysisMode">The dependency analysis mode.</param>
 /// <returns>
 /// An IEnumerable&lt;IGrouping&lt;TKey, TElement&gt;&gt; in C# or IEnumerable(Of IGrouping(Of TKey, TElement)) in Visual Basic where each <see cref="T:System.Linq.IGrouping`2"/> object contains a collection of objects of type TElement and a key.
 /// </returns>
 /// <exception cref="T:System.ArgumentNullException">
 ///     <paramref name="source"/> or <paramref name="keySelector"/> or <paramref name="elementSelector"/> is null.</exception>
 public static IBindableCollection <IBindableGrouping <TKey, TElement> > GroupBy <TSource, TKey, TElement>(this IBindableCollection <TSource> source, Expression <Func <TSource, TKey> > keySelector, Expression <Func <TSource, TElement> > elementSelector, DependencyDiscovery dependencyAnalysisMode)
     where TSource : class
     where TElement : class
 {
     return(source.GroupBy(keySelector, elementSelector, null, dependencyAnalysisMode));
 }