using System.Linq.Expressions; using Connected.Components; namespace Connected { public static class TableExtensions { public static IOrderedEnumerable OrderByDirection(this IEnumerable source, SortDirection direction, Func keySelector) { if (direction == SortDirection.Descending) return source.OrderByDescending(keySelector); return source.OrderBy(keySelector); } public static IOrderedQueryable OrderByDirection(this IQueryable source, SortDirection direction, Expression> keySelector) { if (direction == SortDirection.Descending) return source.OrderByDescending(keySelector); return source.OrderBy(keySelector); } /// /// Disabled the edit button if edit row switching is blocked and the provided item is not being edited /// public static bool EditButtonDisabled(this TableContext context, T item) => (context?.Table.IsEditRowSwitchingBlocked ?? false) && context?.Table._editingItem != null && !ReferenceEquals(context?.Table._editingItem, item); } }