private static string GetSortValue(SObject Instance, SortingProperty Property) { switch (Property) { case SortingProperty.Name: return(Instance.DisplayName); case SortingProperty.Id: return(Instance.ParentSheetIndex.ToString("D4")); case SortingProperty.Category: return(string.Format("{0} {1}", Instance.getCategoryName(), Instance.getCategorySortValue().ToString("D3"))); case SortingProperty.SingleValue: return(ItemBag.GetSingleItemPrice(Instance).ToString("D6")); default: throw new NotImplementedException(string.Format("Unimplemented {0} '{1}' in {2}.{3}", nameof(SortingProperty), Property, nameof(CommandHandler), nameof(GetSortValue))); } }
set => SetValue(SortingProperty, value);
private static IOrderedEnumerable <SObject> ApplySorting(IEnumerable <SObject> Source, SortingProperty Property, SortingOrder Direction) { if (Source is IOrderedEnumerable <SObject> OrderedSource) { if (Direction == SortingOrder.Ascending) { return(OrderedSource.ThenBy(x => GetSortValue(x, Property))); } else { return(OrderedSource.ThenByDescending(x => GetSortValue(x, Property))); } } else { if (Direction == SortingOrder.Ascending) { return(Source.OrderBy(x => GetSortValue(x, Property))); } else { return(Source.OrderByDescending(x => GetSortValue(x, Property))); } } }
public Sorting(SortingDirection direction, SortingProperty property) { Direction = direction; Property = property; }