123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using System;
- using System.Collections.Generic;
- namespace ZenFulcrum.EmbeddedBrowser.Promises
- {
- /// <summary>
- /// General extensions to LINQ.
- /// </summary>
- public static class EnumerableExt
- {
- public static IEnumerable<T> Empty<T>()
- {
- return new T[0];
- }
- public static IEnumerable<T> LazyEach<T>(this IEnumerable<T> source, Action<T> fn)
- {
- foreach (var item in source)
- {
- fn.Invoke(item);
- yield return item;
- }
- }
- public static void Each<T>(this IEnumerable<T> source, Action<T> fn)
- {
- foreach (var item in source)
- {
- fn.Invoke(item);
- }
- }
- public static void Each<T>(this IEnumerable<T> source, Action<T, int> fn)
- {
- int index = 0;
- foreach (T item in source)
- {
- fn.Invoke(item, index);
- index++;
- }
- }
- }
- }
|