You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
609 B

2 years ago
using System;
using System.ComponentModel.DataAnnotations;
namespace Win_in.Sfs.Shared;
public static class DisplayNameExtensions
{
public static string GetNameOfDisplay(this Type type)
{
var displayName = type.Name;
var attrs = type.GetCustomAttributes(typeof(DisplayAttribute), true);
if (attrs.Length == 0)
{
return displayName;
}
var nameOfDisplay = ((DisplayAttribute)attrs[0]).Name;
if (!string.IsNullOrEmpty(nameOfDisplay))
{
displayName = nameOfDisplay;
}
return displayName;
}
}