using System; using System.Linq; using System.Collections.Generic; using BFR.Helpers; namespace BFR.Operations { public class SortOperationMode : OperationMode { public bool IsAlphanumerical => Index == SortMode.Normal; public bool IsNatural => Index == SortMode.Natural; public bool IsLength => Index == SortMode.Length; public bool IsReverse => Index == SortMode.Reverse; public static readonly SortOperationMode[] Modes = All(); protected static SortOperationMode[] All() => ((IEnumerable)Enum.GetValues(typeof(SortMode))).Select(x => new SortOperationMode( x, x.GetAttribute().DisplayName, x.GetAttribute().Description )).ToArray(); public SortOperationMode(SortMode index, string name, string description) : base(index, name, description) { } } public enum SortMode { [OperationMode(nameof(Normal), "Compares file names based on current culture.")] Normal, [OperationMode(nameof(Ordinal), "Compares each successive ordinal character in a string (each character as its ASCII number value).")] Ordinal, [OperationMode(nameof(Natural), "Sorts by natural sort order (numeric values grouped).")] Natural, [OperationMode(nameof(Length), "Sorts by file name length.")] Length, [OperationMode(nameof(Reverse), "Reverses the list order.")] Reverse, } public enum SortDirection { Ascending, Descending } }