src/GenFx.Wpf/DisplayNameHelper.cs
/// <summary>
/// Returns a display name for the specified object.
/// </summary>
/// <param name="obj">The object to get a display name for.</param>
/// <returns>A display name for the specified object.</returns>
Returns a display name for the specified object.
Returns a display name for the specified object .
public static string GetDisplayName(object obj)
        {
            DisplayNameAttribute attrib = obj.GetType().GetCustomAttributes(typeof(DisplayNameAttribute), true)
                .Cast<DisplayNameAttribute>()
                .FirstOrDefault();
            if (attrib != null)
            {
                return attrib.DisplayName;
            }
            string? toString = obj.ToString();
            if (toString != obj.GetType().FullName)
            {
                return toString ?? String.Empty;
            }
            return obj.GetType().Name;
        }
public static string GetDisplayName ( object obj ) { DisplayNameAttribute attrib = obj . GetType ( ) . GetCustomAttributes ( typeof ( DisplayNameAttribute ) , true ) . Cast < DisplayNameAttribute > ( ) . FirstOrDefault ( ) ; if ( attrib != null ) { return attrib . DisplayName ; } string ? toString = obj . ToString ( ) ; if ( toString != obj . GetType ( ) . FullName ) { return toString ?? String . Empty ; } return obj . GetType ( ) . Name ; }
Returns a display name for the specified object.
Returns a display name for the specified object .
A display name for the specified object.
A display name for the specified object .
obj
object
The object to get a display name for.
The object to get a display name for .