예제 #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));
        }
예제 #2
0
파일: Buffer.cs 프로젝트: jnm2/corefx
        /// <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);
            }
        }
예제 #3
0
        public IGrouping <TKey, TElement>[] ToArray()
        {
            IIListProvider <IGrouping <TKey, TElement> > lookup = Lookup <TKey, TElement> .Create(_source, _keySelector, _elementSelector, _comparer);

            return(lookup.ToArray());
        }