From ccd9a0efe245f24ab095c1dc2552a9485831c067 Mon Sep 17 00:00:00 2001 From: adroslice Date: Thu, 21 Nov 2019 19:23:25 +0100 Subject: [PATCH] Merged DisplayName and Description attributes into OperationModeAttribute --- BFR/Operations/Attributes/DescriptionAttribute.cs | 12 ------------ BFR/Operations/Attributes/DisplayNameAttribute.cs | 12 ------------ BFR/Operations/OperationModeAttribute.cs | 13 +++++++++++++ BFR/Operations/ReplaceMode.cs | 15 +++++++-------- 4 files changed, 20 insertions(+), 32 deletions(-) delete mode 100644 BFR/Operations/Attributes/DescriptionAttribute.cs delete mode 100644 BFR/Operations/Attributes/DisplayNameAttribute.cs create mode 100644 BFR/Operations/OperationModeAttribute.cs diff --git a/BFR/Operations/Attributes/DescriptionAttribute.cs b/BFR/Operations/Attributes/DescriptionAttribute.cs deleted file mode 100644 index 57b32b6..0000000 --- a/BFR/Operations/Attributes/DescriptionAttribute.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace BFR.Operations.Attributes -{ - class DescriptionAttribute : Attribute - { - public string Description { get; } - - public DescriptionAttribute(string description) => - Description = description; - } -} diff --git a/BFR/Operations/Attributes/DisplayNameAttribute.cs b/BFR/Operations/Attributes/DisplayNameAttribute.cs deleted file mode 100644 index 6982347..0000000 --- a/BFR/Operations/Attributes/DisplayNameAttribute.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace BFR.Operations.Attributes -{ - class DisplayNameAttribute : Attribute - { - public string DisplayName { get; } - - public DisplayNameAttribute(string displayName) => - DisplayName = displayName; - } -} diff --git a/BFR/Operations/OperationModeAttribute.cs b/BFR/Operations/OperationModeAttribute.cs new file mode 100644 index 0000000..4737703 --- /dev/null +++ b/BFR/Operations/OperationModeAttribute.cs @@ -0,0 +1,13 @@ +using System; + +namespace BFR.Operations +{ + class OperationModeAttribute : Attribute + { + public string DisplayName { get; } + public string Description { get; } + + public OperationModeAttribute(string displayName, string description) => + (DisplayName, Description) = (displayName, description); + } +} diff --git a/BFR/Operations/ReplaceMode.cs b/BFR/Operations/ReplaceMode.cs index 877c1af..03b6b28 100644 --- a/BFR/Operations/ReplaceMode.cs +++ b/BFR/Operations/ReplaceMode.cs @@ -3,7 +3,6 @@ using System.Linq; using System.Collections.Generic; using BFR.Helpers; -using BFR.Operations.Attributes; namespace BFR.Operations { @@ -23,22 +22,22 @@ namespace BFR.Operations protected static ReplaceOperationMode[] All() => ((IEnumerable)Enum.GetValues(typeof(ReplaceMode))).Select(x => new ReplaceOperationMode( x, - x.GetAttribute().DisplayName, - x.GetAttribute().Description + x.GetAttribute().DisplayName, + x.GetAttribute().Description )).ToArray(); } public enum ReplaceMode { - [DisplayName(nameof(Pattern)), Description("Replaces the specified pattern.")] + [OperationMode(nameof(Pattern), "Replaces the specified pattern.")] Pattern, - [DisplayName(nameof(Characters)), Description("Replaces each of the specified characters.")] + [OperationMode(nameof(Characters), "Replaces each of the specified characters.")] Characters, - [DisplayName("From N to N"), Description("Replaces everything in the specified range (zero-based indeces).")] + [OperationMode("From N to N", "Replaces everything in the specified range (zero-based indeces).")] FromNToN, - [DisplayName("First N"), Description("Replaces the first N characters.")] + [OperationMode("First N", "Replaces the first N characters.")] FirstN, - [DisplayName("Last N"), Description("Replaces the last N characters.")] + [OperationMode("Last N", "Replaces the last N characters.")] LastN, } }