DisplayNameHelper kifejlesztése
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WorkFlowCheck.Common.Helper
|
||||
{
|
||||
public static class DisplayNameHelper
|
||||
{
|
||||
public static string GetDisplayName(string propertyName, Type modelType)
|
||||
{
|
||||
var property = modelType.GetProperty(propertyName);
|
||||
var displayNameAttribute = property?.GetCustomAttributes(typeof(DisplayNameAttribute), false)
|
||||
.FirstOrDefault() as DisplayNameAttribute;
|
||||
|
||||
return displayNameAttribute?.DisplayName ?? propertyName;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user