bfr/BFR/Operations/SortMode.cs

50 lines
1.6 KiB
C#
Raw Permalink Normal View History

2019-11-23 17:32:10 +00:00
using System;
using System.Linq;
using System.Collections.Generic;
using BFR.Helpers;
namespace BFR.Operations
{
public class SortOperationMode : OperationMode<SortMode>
{
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<SortMode>)Enum.GetValues(typeof(SortMode))).Select(x =>
new SortOperationMode(
x,
x.GetAttribute<OperationModeAttribute>().DisplayName,
x.GetAttribute<OperationModeAttribute>().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
}
}