You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.0 KiB
45 lines
1.0 KiB
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++; |
|
} |
|
} |
|
} |
|
}
|
|
|