-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/elastic-client
- Loading branch information
Showing
15 changed files
with
479 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: 2 | ||
updates: | ||
|
||
- package-ecosystem: nuget | ||
directory: "/" | ||
schedule: | ||
interval: weekly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/Foundatio.Parsers.ElasticQueries/Foundatio.Parsers.ElasticQueries.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/Foundatio.Parsers.SqlQueries/Extensions/EnumerableExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Foundatio.Parsers.SqlQueries.Extensions; | ||
|
||
internal static class EnumerableExtensions { | ||
public delegate void ElementAction<in T>(T element, ElementInfo info); | ||
|
||
public static void ForEach<T>(this IEnumerable<T> elements, ElementAction<T> action) | ||
{ | ||
using IEnumerator<T> enumerator = elements.GetEnumerator(); | ||
bool isFirst = true; | ||
bool hasNext = enumerator.MoveNext(); | ||
int index = 0; | ||
|
||
while (hasNext) | ||
{ | ||
T current = enumerator.Current; | ||
hasNext = enumerator.MoveNext(); | ||
action(current, new ElementInfo(index, isFirst, !hasNext)); | ||
isFirst = false; | ||
index++; | ||
} | ||
} | ||
|
||
public struct ElementInfo { | ||
public ElementInfo(int index, bool isFirst, bool isLast) | ||
: this() { | ||
Index = index; | ||
IsFirst = isFirst; | ||
IsLast = isLast; | ||
} | ||
|
||
public int Index { get; private set; } | ||
public bool IsFirst { get; private set; } | ||
public bool IsLast { get; private set; } | ||
} | ||
} | ||
|
Oops, something went wrong.