Beispiel #1
0
        /// <summary>
        /// Creates name for the type
        /// </summary>
        /// <param name="type">The type</param>
        /// <returns>The type name</returns>
        public static string GetTypeName(Type type)
        {
            var listType = CheckType(type, typeof(List <>));

            if (listType != null)
            {
                return($"List<{GetTypeName(listType.GenericTypeArguments[0])}>");
            }

            var attr = type.GetTypeInfo().GetCustomAttribute <ApiDescriptionAttribute>();
            var name = attr?.GetName(type) ?? NamingUtilities.ToCSharpRepresentation(type);

            return(type.GetTypeInfo().IsGenericType&& !string.IsNullOrWhiteSpace(attr?.GetName(type))
                       ? $"{name}<{string.Join(",", type.GetGenericArguments().Select(GetTypeName))}>"
                       : name);
        }
Beispiel #2
0
 /// <summary>
 /// Creates name for the type
 /// </summary>
 /// <param name="type">The type</param>
 /// <returns>The type name</returns>
 public string GetName(Type type)
 {
     return(this.Name ?? NamingUtilities.ToCSharpRepresentation(type));
 }