bfr/BFR/Operations/AddMode.cs
2019-11-22 19:34:21 +01:00

38 lines
1.2 KiB
C#

using System;
using System.Linq;
using System.Collections.Generic;
using BFR.Helpers;
namespace BFR.Operations
{
public class AddOperationMode : OperationMode<AddMode>
{
public bool IsPrepend => Index == AddMode.Prepend;
public bool IsAppend => Index == AddMode.Append;
public bool IsInsert => Index == AddMode.Insert;
public readonly static AddOperationMode[] Modes = All();
public AddOperationMode(AddMode index, string name, string description) :
base(index, name, description) { }
protected static AddOperationMode[] All() => ((IEnumerable<AddMode>)Enum.GetValues(typeof(AddMode))).Select(x =>
new AddOperationMode(
x,
x.GetAttribute<OperationModeAttribute>().DisplayName,
x.GetAttribute<OperationModeAttribute>().Description
)).ToArray();
}
public enum AddMode
{
[OperationMode(nameof(Prepend), "Inserts before the file name.")]
Prepend,
[OperationMode(nameof(Append), "Inserts after the file name.")]
Append,
[OperationMode(nameof(Insert), "Inserts at the specified index.")]
Insert
}
}