Ejemplo n.º 1
0
        public static TSource[] ToArray <TSource>(this IEnumerable <TSource> source)
        {
            if (source == null)
            {
                throw Error.ArgumentNull("source");
            }
            IIListProvider <TSource> arrayProvider = source as IIListProvider <TSource>;

            return(arrayProvider != null?arrayProvider.ToArray() : EnumerableHelpers.ToArray(source));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Fully enumerates the provided enumerable and stores its items into an array.
        /// </summary>
        /// <param name="source">The enumerable to be store.</param>
        internal Buffer(IEnumerable <TElement> source)
        {
            IIListProvider <TElement> iterator = source as IIListProvider <TElement>;

            if (iterator != null)
            {
                TElement[] array = iterator.ToArray();
                _items = array;
                _count = array.Length;
            }
            else
            {
                _items = EnumerableHelpers.ToArray(source, out _count);
            }
        }
Ejemplo n.º 3
0
        public IGrouping <TKey, TElement>[] ToArray()
        {
            IIListProvider <IGrouping <TKey, TElement> > lookup = Lookup <TKey, TElement> .Create(_source, _keySelector, _elementSelector, _comparer);

            return(lookup.ToArray());
        }