Merged DisplayName and Description attributes into OperationModeAttribute
This commit is contained in:
parent
ae7c3a3fff
commit
ccd9a0efe2
|
@ -1,12 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace BFR.Operations.Attributes
|
|
||||||
{
|
|
||||||
class DescriptionAttribute : Attribute
|
|
||||||
{
|
|
||||||
public string Description { get; }
|
|
||||||
|
|
||||||
public DescriptionAttribute(string description) =>
|
|
||||||
Description = description;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace BFR.Operations.Attributes
|
|
||||||
{
|
|
||||||
class DisplayNameAttribute : Attribute
|
|
||||||
{
|
|
||||||
public string DisplayName { get; }
|
|
||||||
|
|
||||||
public DisplayNameAttribute(string displayName) =>
|
|
||||||
DisplayName = displayName;
|
|
||||||
}
|
|
||||||
}
|
|
13
BFR/Operations/OperationModeAttribute.cs
Normal file
13
BFR/Operations/OperationModeAttribute.cs
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,7 +3,6 @@ using System.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using BFR.Helpers;
|
using BFR.Helpers;
|
||||||
using BFR.Operations.Attributes;
|
|
||||||
|
|
||||||
namespace BFR.Operations
|
namespace BFR.Operations
|
||||||
{
|
{
|
||||||
|
@ -23,22 +22,22 @@ namespace BFR.Operations
|
||||||
protected static ReplaceOperationMode[] All() => ((IEnumerable<ReplaceMode>)Enum.GetValues(typeof(ReplaceMode))).Select(x =>
|
protected static ReplaceOperationMode[] All() => ((IEnumerable<ReplaceMode>)Enum.GetValues(typeof(ReplaceMode))).Select(x =>
|
||||||
new ReplaceOperationMode(
|
new ReplaceOperationMode(
|
||||||
x,
|
x,
|
||||||
x.GetAttribute<DisplayNameAttribute>().DisplayName,
|
x.GetAttribute<OperationModeAttribute>().DisplayName,
|
||||||
x.GetAttribute<DescriptionAttribute>().Description
|
x.GetAttribute<OperationModeAttribute>().Description
|
||||||
)).ToArray();
|
)).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum ReplaceMode
|
public enum ReplaceMode
|
||||||
{
|
{
|
||||||
[DisplayName(nameof(Pattern)), Description("Replaces the specified pattern.")]
|
[OperationMode(nameof(Pattern), "Replaces the specified pattern.")]
|
||||||
Pattern,
|
Pattern,
|
||||||
[DisplayName(nameof(Characters)), Description("Replaces each of the specified characters.")]
|
[OperationMode(nameof(Characters), "Replaces each of the specified characters.")]
|
||||||
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,
|
FromNToN,
|
||||||
[DisplayName("First N"), Description("Replaces the first N characters.")]
|
[OperationMode("First N", "Replaces the first N characters.")]
|
||||||
FirstN,
|
FirstN,
|
||||||
[DisplayName("Last N"), Description("Replaces the last N characters.")]
|
[OperationMode("Last N", "Replaces the last N characters.")]
|
||||||
LastN,
|
LastN,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user