/// <summary>Returns the first element of a sequence, or a default value if the sequence contains no elements.</summary> /// <returns>default(<typeparamref name="TSource" />) if <paramref name="source" /> is empty; otherwise, the first element in <paramref name="source" />.</returns> /// <param name="source">The <see cref="IBindableCollection{TElement}" /> to return the first element of.</param> /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="source" /> is null.</exception> public static IBindable <TSource> FirstOrDefault <TSource>(this IBindableCollection <TSource> source) { source.ShouldNotBeNull("source"); return(source.ElementAtOrDefault(0)); }
/// <summary>Returns the last element of a sequence, or a default value if the sequence contains no elements.</summary> /// <returns>default(<typeparamref name="TSource" />) if the source sequence is empty; otherwise, the last element in the <see cref="IBindableCollection{TElement}" />.</returns> /// <param name="source">An <see cref="IBindableCollection{TElement}" /> to return the last element of.</param> /// <typeparam name="TSource">The type of the elements of <paramref name="source" />.</typeparam> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="source" /> is null.</exception> public static IBindable <TSource> LastOrDefault <TSource>(this IBindableCollection <TSource> source) { return(source.ElementAtOrDefault(-1)); }