Add row and column accessors for tables and grids

This commit is contained in:
Patrik Svensson
2020-10-26 11:51:35 +01:00
committed by Patrik Svensson
parent 3e5e22d6c2
commit e7f497050c
30 changed files with 511 additions and 162 deletions

View File

@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace Spectre.Console.Internal.Collections
{
internal sealed class ListWithCallback<T> : IList<T>
internal sealed class ListWithCallback<T> : IList<T>, IReadOnlyList<T>
{
private readonly List<T> _list;
private readonly Action _callback;

View File

@ -6,6 +6,21 @@ namespace Spectre.Console.Internal
{
internal static class EnumerableExtensions
{
public static int GetCount<T>(this IEnumerable<T> source)
{
if (source is IList<T> list)
{
return list.Count;
}
if (source is T[] array)
{
return array.Length;
}
return source.Count();
}
public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
{
foreach (var item in source)