bfr/BFR/Operations/AddMode.cs

38 lines
1.2 KiB
C#
Raw Permalink Normal View History

2019-11-22 18:34:21 +00:00
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
}
}