Antaris.AspNetCore.Mvc.Widgets.Internal.WidgetConventions.GetWidgetName C# (CSharp) Method

GetWidgetName() public static method

Gets the widget name for the given widget type.
public static GetWidgetName ( TypeInfo widgetType ) : string
widgetType System.Reflection.TypeInfo The widget type.
return string
        public static string GetWidgetName(TypeInfo widgetType)
        {
            if (widgetType == null)
            {
                throw new ArgumentNullException(nameof(widgetType));
            }

            var attr = widgetType.GetCustomAttribute<WidgetAttribute>();
            if (attr != null && !string.IsNullOrEmpty(attr.Name))
            {
                var idx = attr.Name.LastIndexOf('.');
                if (idx >= 0)
                {
                    return attr.Name.Substring(idx + 1);
                }

                return attr.Name;
            }

            return GetShortNameByConvention(widgetType);
        }