Ban rewrite

This commit is contained in:
Chris 2020-11-15 11:05:04 +10:30
parent 5af1f8f76a
commit 56de9f6684
9 changed files with 679 additions and 860 deletions

View file

@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Collections.Generic;
using System.Linq;
namespace TShockAPI
{
@ -31,5 +32,25 @@ namespace TShockAPI
foreach (T item in source)
action(item);
}
/// <summary>
/// Attempts to retrieve the value at the given index from the enumerable
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="enumerable"></param>
/// <param name="index"></param>
/// <param name="value"></param>
/// <returns></returns>
public static bool TryGetValue<T>(this IEnumerable<T> enumerable, int index, out T value)
{
if (index < enumerable.Count())
{
value = enumerable.ElementAt(index);
return true;
}
value = default;
return false;
}
}
}
}