mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-05-26 08:57:06 +00:00
Move Common functionality to Core project & rendering and Model support as well
This commit is contained in:
38
PckStudio.Core/Extensions/EnumerableExtensions.cs
Normal file
38
PckStudio.Core/Extensions/EnumerableExtensions.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace PckStudio.Core.Extensions
|
||||
{
|
||||
public static class EnumerableExtensions
|
||||
{
|
||||
public static IEnumerable<(int index, T value)>enumerate<T>(this IEnumerable<T> array)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (T item in array)
|
||||
{
|
||||
yield return (i++, item);
|
||||
}
|
||||
yield break;
|
||||
}
|
||||
|
||||
public static bool EqualsAny<T>(this T type, params T[] items)
|
||||
{
|
||||
foreach (T item in items)
|
||||
{
|
||||
if (item.Equals(type))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool ContainsAny<T>(this IEnumerable<T> array, params T[] items)
|
||||
{
|
||||
foreach (T item in array)
|
||||
{
|
||||
if (items.Contains(item))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user