System.Collections.Generic.IEnumerable.GetEnumerator()

Here are the examples of the csharp api System.Collections.Generic.IEnumerable.GetEnumerator() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3559 Examples 7

19 Source : ListSnapshot.cs
with MIT License
from 0x0ade

public IEnumerator<T> GetEnumerator() {
            return ((IEnumerable<T>) List).GetEnumerator();
        }

19 Source : Ext.cs
with GNU General Public License v3.0
from 1330-Studios

public static Il2CppReferenceArray<T> Add<T>(this Il2CppReferenceArray<T> reference, IEnumerable<T> enumerable) where T : Model {
            var bases = new List<T>();
            foreach (var tmp in reference)
                bases.Add(tmp);

            var enumerator = enumerable.GetEnumerator();
            while (enumerator.MoveNext()) bases.Add(enumerator.Current);

            return new(bases.ToArray());
        }

19 Source : Ext.cs
with GNU General Public License v3.0
from 1330-Studios

public static Il2CppSystem.Collections.Generic.IEnumerable<C> SelectI<T, R, C>(this IEnumerable<T> enumerable, Func<T, R> predicate) where R : Model where C : Model {
            var bases = new Il2CppSystem.Collections.Generic.List<C>();
            var enumerator = enumerable.GetEnumerator();
            while (enumerator.MoveNext())
                bases.Add(predicate(enumerator.Current).Cast<C>());
            return bases.Cast<Il2CppSystem.Collections.Generic.IEnumerable<C>>();
        }

19 Source : BssMapObjMarshalReader.cs
with MIT License
from 1996v

public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
        {
            if (Count == 0)
            {
                return Enumerable.Empty<KeyValuePair<TKey, TValue>>().GetEnumerator();
            }

            Reader.BssomBuffer.TryReadFixedRef(Paras.MapHead.RouteLength, out bool haveEnoughSizeAndCanBeFixed);
            if (haveEnoughSizeAndCanBeFixed)
            {
                return new Enumerator(this);
            }
            else
            {
                return new EnumeratorSlow(this);
            }
        }

19 Source : Grouping.cs
with MIT License
from 1996v

public IEnumerator<TElement> GetEnumerator()
        {
            return elements.GetEnumerator();
        }

19 Source : Grouping.cs
with MIT License
from 1996v

IEnumerator IEnumerable.GetEnumerator()
        {
            return elements.GetEnumerator();
        }

19 Source : BindableObjectCollection.cs
with MIT License
from 1iveowl

public IEnumerator<BindableObject> GetEnumerator()
        {
            return _items.GetEnumerator();
        }

19 Source : RoProperties.cs
with MIT License
from 3F

public IEnumerator<KeyValuePair<T, T2>> GetEnumerator() => dict.GetEnumerator();

19 Source : RoProperties.cs
with MIT License
from 3F

IEnumerator IEnumerable.GetEnumerator() => dict.GetEnumerator();

19 Source : JsonData.cs
with MIT License
from 404Lcc

IDictionaryEnumerator IOrderedDictionary.GetEnumerator ()
        {
            EnsureDictionary ();

            return new OrderedDictionaryEnumerator (
                object_list.GetEnumerator ());
        }

19 Source : LightList.cs
with MIT License
from 71

public IEnumerator<T> GetEnumerator() => ((IList<T>)UnderlyingArray).GetEnumerator();

19 Source : ConcurrentQueueCapacityInitializer.cs
with MIT License
from Abc-Arbitrage

public IEnumerator<LogEvent> GetEnumerator() => Enumerable.Empty<LogEvent>().GetEnumerator();

19 Source : FdbMemoizedTuple.cs
with MIT License
from abdullin

public IEnumerator<object> GetEnumerator()
		{
			return ((IList<object>)m_items).GetEnumerator();
		}

19 Source : FdbListTuple.cs
with MIT License
from abdullin

public IEnumerator<object> GetEnumerator()
		{
			if (m_offset == 0 && m_count == m_items.Length)
			{
				return ((IList<object>)m_items).GetEnumerator();
			}
			return Enumerate(m_items, m_offset, m_count);
		}

19 Source : EnumerableExtensions.cs
with Apache License 2.0
from abist-co-ltd

public static T MaxOrDefault<T>(this IEnumerable<T> items, IComparer<T> comparer = null)
        {
            if (items == null) { throw new ArgumentNullException("items"); }
            comparer = comparer ?? Comparer<T>.Default;

            using (var enumerator = items.GetEnumerator())
            {
                if (!enumerator.MoveNext())
                {
                    return default(T);
                }

                var max = enumerator.Current;
                while (enumerator.MoveNext())
                {
                    if (comparer.Compare(max, enumerator.Current) < 0)
                    {
                        max = enumerator.Current;
                    }
                }
                return max;
            }
        }

19 Source : ActivityDefinitionList.cs
with Apache License 2.0
from AbpApp

public IEnumerator<ActivityDescriptor> GetEnumerator() => Items.Values.GetEnumerator();

19 Source : DispatcherObservableCollection.cs
with MIT License
from ABTSoftware

public IEnumerator<T> GetEnumerator()
        {
            return _collection.GetEnumerator();
        }

19 Source : DispatcherObservableCollection.cs
with MIT License
from ABTSoftware

System.Collections.IEnumerator System.Collections
            .IEnumerable.GetEnumerator()
        {
            return _collection.GetEnumerator();
        }

19 Source : ConcurrentList.cs
with MIT License
from Accelerider

public IEnumerator<T> GetEnumerator()
        {
            lock (_storage)
            {
                var temp = new T[_storage.Count];
                _storage.CopyTo(temp, 0);
                return temp.Cast<T>().GetEnumerator();
            }
        }

19 Source : QueryableExtensions.cs
with GNU Affero General Public License v3.0
from ACEmulator

public static string ToSql<TEnreplacedy>(this IQueryable<TEnreplacedy> query)
        {
            var enumerator = query.Provider.Execute<IEnumerable<TEnreplacedy>>(query.Expression).GetEnumerator();
            var enumeratorType = enumerator.GetType();
            var selectFieldInfo = enumeratorType.GetField("_selectExpression", BindingFlags.NonPublic | BindingFlags.Instance) ?? throw new InvalidOperationException($"cannot find field _selectExpression on type {enumeratorType.Name}");
            var sqlGeneratorFieldInfo = enumeratorType.GetField("_querySqlGeneratorFactory", BindingFlags.NonPublic | BindingFlags.Instance) ?? throw new InvalidOperationException($"cannot find field _querySqlGeneratorFactory on type {enumeratorType.Name}");
            var selectExpression = selectFieldInfo.GetValue(enumerator) as SelectExpression ?? throw new InvalidOperationException($"could not get SelectExpression");
            var factory = sqlGeneratorFieldInfo.GetValue(enumerator) as IQuerySqlGeneratorFactory ?? throw new InvalidOperationException($"could not get IQuerySqlGeneratorFactory");
            var sqlGenerator = factory.Create();
            var command = sqlGenerator.GetCommand(selectExpression);
            var sql = command.CommandText;

            return sql;
        }

19 Source : EnumerableExtensions.cs
with MIT License
from actions

public static IEnumerable<T> Merge<T>(
            this IEnumerable<T> first,
            IEnumerable<T> second,
            Func<T, T, int> comparer)
        {
            ArgumentUtility.CheckForNull(first, nameof(first));
            ArgumentUtility.CheckForNull(second, nameof(second));
            ArgumentUtility.CheckForNull(comparer, nameof(comparer));

            using (IEnumerator<T> e1 = first.GetEnumerator())
            using (IEnumerator<T> e2 = second.GetEnumerator())
            {
                bool e1Valid = e1.MoveNext();
                bool e2Valid = e2.MoveNext();

                while (e1Valid && e2Valid)
                {
                    if (comparer(e1.Current, e2.Current) <= 0)
                    {
                        yield return e1.Current;

                        e1Valid = e1.MoveNext();
                    }
                    else
                    {
                        yield return e2.Current;

                        e2Valid = e2.MoveNext();
                    }
                }

                while (e1Valid)
                {
                    yield return e1.Current;

                    e1Valid = e1.MoveNext();
                }

                while (e2Valid)
                {
                    yield return e2.Current;

                    e2Valid = e2.MoveNext();
                }
            }
        }

19 Source : EnumerableExtensions.cs
with MIT License
from actions

public static IEnumerable<T> MergeDistinct<T>(
            this IEnumerable<T> first,
            IEnumerable<T> second,
            Func<T, T, int> comparer)
        {
            ArgumentUtility.CheckForNull(first, nameof(first));
            ArgumentUtility.CheckForNull(second, nameof(second));
            ArgumentUtility.CheckForNull(comparer, nameof(comparer));

            using (IEnumerator<T> e1 = first.GetEnumerator())
            using (IEnumerator<T> e2 = second.GetEnumerator())
            {
                bool e1Valid = e1.MoveNext();
                bool e2Valid = e2.MoveNext();

                while (e1Valid && e2Valid)
                {
                    if (comparer(e1.Current, e2.Current) < 0)
                    {
                        yield return e1.Current;

                        e1Valid = e1.MoveNext();
                    }
                    else if (comparer(e1.Current, e2.Current) > 0)
                    {
                        yield return e2.Current;

                        e2Valid = e2.MoveNext();
                    }
                    else
                    {
                        yield return e1.Current;

                        e1Valid = e1.MoveNext();
                        e2Valid = e2.MoveNext();
                    }
                }

                while (e1Valid)
                {
                    yield return e1.Current;

                    e1Valid = e1.MoveNext();
                }

                while (e2Valid)
                {
                    yield return e2.Current;

                    e2Valid = e2.MoveNext();
                }
            }
        }

19 Source : TemplateValidationErrors.cs
with MIT License
from actions

public IEnumerator<TemplateValidationError> GetEnumerator()
        {
            return (m_errors as IEnumerable<TemplateValidationError>).GetEnumerator();
        }

19 Source : Index.cs
with MIT License
from actions

public IEnumerator GetEnumerator() => m_list.GetEnumerator();

19 Source : SequenceToken.cs
with MIT License
from actions

public IEnumerator<TemplateToken> GetEnumerator()
        {
            if (m_items?.Count > 0)
            {
                return m_items.GetEnumerator();
            }
            else
            {
                return (new TemplateToken[0] as IEnumerable<TemplateToken>).GetEnumerator();
            }
        }

19 Source : SequenceToken.cs
with MIT License
from actions

IEnumerator IEnumerable.GetEnumerator()
        {
            if (m_items?.Count > 0)
            {
                return m_items.GetEnumerator();
            }
            else
            {
                return (new TemplateToken[0] as IEnumerable<TemplateToken>).GetEnumerator();
            }
        }

19 Source : SequenceToken.cs
with MIT License
from actions

IEnumerator IReadOnlyArray.GetEnumerator()
        {
            if (m_items?.Count > 0)
            {
                return m_items.GetEnumerator();
            }
            else
            {
                return (new TemplateToken[0] as IEnumerable<TemplateToken>).GetEnumerator();
            }
        }

19 Source : PropertiesCollection.cs
with MIT License
from actions

IEnumerator<KeyValuePair<String, Object>> IEnumerable<KeyValuePair<String, Object>>.GetEnumerator()
        {
            return ((IEnumerable<KeyValuePair<String, Object>>)m_innerDictionary).GetEnumerator();
        }

19 Source : MCompositeDetails.cs
with GNU Affero General Public License v3.0
from active-logic

status Ordered(){
        ι = ι ?? tasks.GetEnumerator();
        if(task == null){
            if(ι.MoveNext()) task = ι.Current;
            else return current;
        }
        current = task();
        if(current == key){
            if(ι.MoveNext()) { task = ι.Current; return cont; }
            else             { task = null;                   }
        }
        return current;
    }

19 Source : EnumerableExtraExtensions.cs
with GNU General Public License v3.0
from Acumatica

public static bool IsSorted<T>(this IEnumerable<T> enumerable, IComparer<T> comparer)
		{
			using var e = enumerable.GetEnumerator();

			if (!e.MoveNext())
			{
				return true;
			}

			var previous = e.Current;

			while (e.MoveNext())
			{
				if (comparer.Compare(previous, e.Current) > 0)
				{
					return false;
				}

				previous = e.Current;
			}

			return true;
		}

19 Source : EnumerableExtraExtensions.cs
with GNU General Public License v3.0
from Acumatica

public static bool SequenceEqual<T>(this IEnumerable<T> first, IEnumerable<T> second, Func<T, T, bool> comparer)
		{
			Debug.replacedert(comparer != null);

			if (first == second)
			{
				return true;
			}

			if (first == null || second == null)
			{
				return false;
			}

			using (var enumerator = first.GetEnumerator())
			using (var enumerator2 = second.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					if (!enumerator2.MoveNext() || !comparer(enumerator.Current, enumerator2.Current))
					{
						return false;
					}
				}

				if (enumerator2.MoveNext())
				{
					return false;
				}
			}

			return true;
		}

19 Source : EnumerableExtraExtensions.cs
with GNU General Public License v3.0
from Acumatica

public static bool IsSingle<T>(this IEnumerable<T> list)
		{
			if (list == null)
				return false;

			using var enumerator = list.GetEnumerator();
			return enumerator.MoveNext() && !enumerator.MoveNext();
		}

19 Source : TagsCacheAsync.cs
with GNU General Public License v3.0
from Acumatica

public IEnumerator<ITagSpan<TTag>> GetEnumerator() => ProcessedTags.GetEnumerator();

19 Source : EnumerableExtensions.cs
with MIT License
from adamant

public IEnumerator<T> GetEnumerator()
            {
                return source.GetEnumerator();
            }

19 Source : EnumerableExtensions.cs
with MIT License
from adamant

IEnumerator IEnumerable.GetEnumerator()
            {
                return source.GetEnumerator();
            }

19 Source : FixedDictionary.cs
with MIT License
from adamant

[DebuggerStepThrough]
        public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator()
        {
            return items.GetEnumerator();
        }

19 Source : FixedList.cs
with MIT License
from adamant

[DebuggerStepThrough]
        public IEnumerator<T> GetEnumerator()
        {
            return items.GetEnumerator();
        }

19 Source : DataArray.cs
with MIT License
from adamtiger

public IEnumerator<double> GetEnumerator()
        {
            var ret = ((IEnumerable<double>)array).GetEnumerator();
            return ret;
        }

19 Source : StreamExtent.cs
with MIT License
from ADeltaX

public static IEnumerable<StreamExtent> Union(params IEnumerable<StreamExtent>[] streams)
        {
            long extentStart = long.MaxValue;
            long extentEnd = 0;

            // Initialize enumerations and find first stored byte position
            IEnumerator<StreamExtent>[] enums = new IEnumerator<StreamExtent>[streams.Length];
            bool[] streamsValid = new bool[streams.Length];
            int validStreamsRemaining = 0;
            for (int i = 0; i < streams.Length; ++i)
            {
                enums[i] = streams[i].GetEnumerator();
                streamsValid[i] = enums[i].MoveNext();
                if (streamsValid[i])
                {
                    ++validStreamsRemaining;
                    if (enums[i].Current.Start < extentStart)
                    {
                        extentStart = enums[i].Current.Start;
                        extentEnd = enums[i].Current.Start + enums[i].Current.Length;
                    }
                }
            }

            while (validStreamsRemaining > 0)
            {
                // Find the end of this extent
                bool foundIntersection;
                do
                {
                    foundIntersection = false;
                    validStreamsRemaining = 0;
                    for (int i = 0; i < streams.Length; ++i)
                    {
                        while (streamsValid[i] && enums[i].Current.Start + enums[i].Current.Length <= extentEnd)
                        {
                            streamsValid[i] = enums[i].MoveNext();
                        }

                        if (streamsValid[i])
                        {
                            ++validStreamsRemaining;
                        }

                        if (streamsValid[i] && enums[i].Current.Start <= extentEnd)
                        {
                            extentEnd = enums[i].Current.Start + enums[i].Current.Length;
                            foundIntersection = true;
                            streamsValid[i] = enums[i].MoveNext();
                        }
                    }
                } while (foundIntersection && validStreamsRemaining > 0);

                // Return the discovered extent
                yield return new StreamExtent(extentStart, extentEnd - extentStart);

                // Find the next extent start point
                extentStart = long.MaxValue;
                validStreamsRemaining = 0;
                for (int i = 0; i < streams.Length; ++i)
                {
                    if (streamsValid[i])
                    {
                        ++validStreamsRemaining;
                        if (enums[i].Current.Start < extentStart)
                        {
                            extentStart = enums[i].Current.Start;
                            extentEnd = enums[i].Current.Start + enums[i].Current.Length;
                        }
                    }
                }
            }
        }

19 Source : StreamExtent.cs
with MIT License
from ADeltaX

public static IEnumerable<StreamExtent> Intersect(params IEnumerable<StreamExtent>[] streams)
        {
            long extentStart = long.MinValue;
            long extentEnd = long.MaxValue;

            IEnumerator<StreamExtent>[] enums = new IEnumerator<StreamExtent>[streams.Length];
            for (int i = 0; i < streams.Length; ++i)
            {
                enums[i] = streams[i].GetEnumerator();
                if (!enums[i].MoveNext())
                {
                    // Gone past end of one stream (in practice was empty), so no intersections
                    yield break;
                }
            }

            int overlapsFound = 0;
            while (true)
            {
                // We keep cycling round the streams, until we get streams.Length continuous overlaps
                for (int i = 0; i < streams.Length; ++i)
                {
                    // Move stream on past all extents that are earlier than our candidate start point
                    while (enums[i].Current.Length == 0
                           || enums[i].Current.Start + enums[i].Current.Length <= extentStart)
                    {
                        if (!enums[i].MoveNext())
                        {
                            // Gone past end of this stream, no more intersections possible
                            yield break;
                        }
                    }

                    // If this stream has an extent that spans over the candidate start point
                    if (enums[i].Current.Start <= extentStart)
                    {
                        extentEnd = Math.Min(extentEnd, enums[i].Current.Start + enums[i].Current.Length);
                        overlapsFound++;
                    }
                    else
                    {
                        extentStart = enums[i].Current.Start;
                        extentEnd = extentStart + enums[i].Current.Length;
                        overlapsFound = 1;
                    }

                    // We've just done a complete loop of all streams, they overlapped this start position
                    // and we've cut the extent's end down to the shortest run.
                    if (overlapsFound == streams.Length)
                    {
                        yield return new StreamExtent(extentStart, extentEnd - extentStart);
                        extentStart = extentEnd;
                        extentEnd = long.MaxValue;
                        overlapsFound = 0;
                    }
                }
            }
        }

19 Source : Utils.cs
with MIT License
from adospace

public static string ToSql<TEnreplacedy>(this IQueryable<TEnreplacedy> query) where TEnreplacedy : clreplaced
        {
            using var enumerator = query.Provider.Execute<IEnumerable<TEnreplacedy>>(query.Expression).GetEnumerator();
            var relationalCommandCache = enumerator.Private("_relationalCommandCache");
            var selectExpression = relationalCommandCache.Private<SelectExpression>("_selectExpression");
            var factory = relationalCommandCache.Private<IQuerySqlGeneratorFactory>("_querySqlGeneratorFactory");

            var sqlGenerator = factory.Create();
            var command = sqlGenerator.GetCommand(selectExpression);

            string sql = command.CommandText;
            return sql;
        }

19 Source : DumpableBsonDocumentCollection.cs
with BSD 2-Clause "Simplified" License
from adospace

public IEnumerator<DumpableBsonDoreplacedent> GetEnumerator()
        {
            return _originalQuery.GetEnumerator();
        }

19 Source : DumpableBsonDocumentCollection.cs
with BSD 2-Clause "Simplified" License
from adospace

IEnumerator IEnumerable.GetEnumerator()
        {
            return _originalQuery.GetEnumerator();
        }

19 Source : MethodHelpers.cs
with MIT License
from ADeltaX

public static IEnumerable<T> SkipLast<T>(this IEnumerable<T> source, int count)
        {
            var e = source.GetEnumerator();
            var cache = new Queue<T>(count + 1);

            using (e = source.GetEnumerator())
            {
                bool hasRemainingItems;
                do
                {
                    if (hasRemainingItems = e.MoveNext())
                    {
                        cache.Enqueue(e.Current);
                        if (cache.Count > count)
                            yield return cache.Dequeue();
                    }
                } while (hasRemainingItems);
            }
        }

19 Source : ActivityCollection.cs
with MIT License
from Adoxio

public IEnumerator<IActivity> GetEnumerator()
		{
			return Enumerable.GetEnumerator();
		}

19 Source : ObservableItemsSource.cs
with MIT License
from adospace

public IEnumerator<T> GetEnumerator()
        {
            return ItemsSource.GetEnumerator();
        }

19 Source : TopPaginator.cs
with MIT License
from Adoxio

public IEnumerator<T> GetEnumerator()
			{
				return _items.GetEnumerator();
			}

19 Source : ObjectShredder.cs
with MIT License
from Adoxio

public DataTable Shred(IEnumerable<T> source, DataTable table, LoadOption? options)
		{
			// Load the table from the scalar sequence if T is a primitive type.
			if (typeof(T).IsPrimitive)
			{
				return ShredPrimitive(source, table, options);
			}

			// Create a new table if the input table is null.
			if (table == null)
			{
				table = new DataTable(typeof(T).Name);
			}

			// Initialize the ordinal map and extend the table schema based on type T.
			table = ExtendTable(table, typeof(T));

			// Enumerate the source sequence and load the object values into rows.
			table.BeginLoadData();
			using (IEnumerator<T> e = source.GetEnumerator())
			{
				while (e.MoveNext())
				{
					if (options != null)
					{
						table.LoadDataRow(ShredObject(table, e.Current), (LoadOption)options);
					}
					else
					{
						table.LoadDataRow(ShredObject(table, e.Current), true);
					}
				}
			}
			table.EndLoadData();

			// Return the table.
			return table;
		}

19 Source : ObjectShredder.cs
with MIT License
from Adoxio

public DataTable ShredPrimitive(IEnumerable<T> source, DataTable table, LoadOption? options)
		{
			// Create a new table if the input table is null.
			if (table == null)
			{
				table = new DataTable(typeof(T).Name);
			}

			if (!table.Columns.Contains("Value"))
			{
				table.Columns.Add("Value", typeof(T));
			}

			// Enumerate the source sequence and load the scalar values into rows.
			table.BeginLoadData();
			using (IEnumerator<T> e = source.GetEnumerator())
			{
				var values = new object[table.Columns.Count];
				while (e.MoveNext())
				{
					values[table.Columns["Value"].Ordinal] = e.Current;

					if (options != null)
					{
						table.LoadDataRow(values, (LoadOption)options);
					}
					else
					{
						table.LoadDataRow(values, true);
					}
				}
			}
			table.EndLoadData();

			// Return the table.
			return table;
		}

19 Source : AnnotationCollection.cs
with MIT License
from Adoxio

public IEnumerator<IAnnotation> GetEnumerator()
		{
			return Enumerable.GetEnumerator();
		}

See More Examples