23 lines
710 B
C#
23 lines
710 B
C#
using System;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
|
|
namespace Kreta.Naplo.Domain.V3.Utility.ValidationAttributes
|
|
{
|
|
[AttributeUsage(AttributeTargets.Property)]
|
|
public class EnumToDescriptionAttribute : DescriptionAttribute
|
|
{
|
|
public override string Description => base.Description;
|
|
|
|
public EnumToDescriptionAttribute(string description, Type enumType)
|
|
{
|
|
DescriptionValue = description + " (" + GetEnumsFromGenerated(enumType) + ")";
|
|
}
|
|
|
|
private string GetEnumsFromGenerated(Type enumType)
|
|
{
|
|
var enumNames = System.Enum.GetNames(enumType).ToList();
|
|
return string.Join(", ", enumNames);
|
|
}
|
|
}
|
|
}
|