mirror of
https://github.com/DevExpress/netcore-winforms-demos.git
synced 2026-01-04 15:56:04 +00:00
19.1.3-ctp
This commit is contained in:
committed by
GitHub
parent
2e45b5d38f
commit
a2371dfb0b
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace DevExpress.DevAV.Reports {
|
||||
static class EnumDisplayTextHelper {
|
||||
public static string GetDisplayText(object value) {
|
||||
MemberInfo[] info = value.GetType().GetMember(value.ToString());
|
||||
object[] attributes = info[0].GetCustomAttributes(false);
|
||||
for(int i = 0; i < attributes.Length; i++) {
|
||||
Type attributeType = attributes[i].GetType();
|
||||
if(attributeType == typeof(System.ComponentModel.DataAnnotations.DisplayAttribute))
|
||||
return (string)attributeType.GetProperty("Name").GetValue(attributes[i], null) ?? string.Empty;
|
||||
}
|
||||
return value.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user