public static string AsFriendlyName(this Type type, PostmanFeature feature) { var parts = type.Name.SplitOnFirst('`'); var typeName = parts[0].SplitOnFirst('[')[0]; var suffix = ""; var nullableType = Nullable.GetUnderlyingType(type); if (nullableType != null) { typeName = nullableType.Name; suffix = "?"; } else if (type.IsArray) { suffix = "[]"; } else if (type.IsGenericType()) { var args = type.GetGenericArguments().Map(x => x.AsFriendlyName(feature)); suffix = "<{0}>".Fmt(string.Join(",", args.ToArray())); } string frindlyName; return(feature.FriendlyTypeNames.TryGetValue(typeName, out frindlyName) ? frindlyName + suffix : typeName + suffix); }
public string GetName(PostmanFeature feature, Postman request, Type requestType, string virtualPath) { var fragments = request.Label ?? feature.DefaultLabelFmt; var sb = new StringBuilder(); foreach (var fragment in fragments) { var parts = fragment.ToLower().Split(':'); var asEnglish = parts.Length > 1 && parts[1] == "english"; if (parts[0] == "type") { sb.Append(asEnglish ? requestType.Name.ToEnglish() : requestType.Name); } else if (parts[0] == "route") { sb.Append(virtualPath); } else { sb.Append(parts[0]); } } return(sb.ToString()); }
public static string AsFriendlyName(this Type type, PostmanFeature feature) { var parts = type.Name.SplitOnFirst('`'); var typeName = parts[0].SplitOnFirst('[')[0]; var suffix = ""; var nullableType = Nullable.GetUnderlyingType(type); if (nullableType != null) { typeName = nullableType.Name; suffix = "?"; } else if (type.IsArray) { suffix = "[]"; } else if (type.IsGenericType()) { var args = type.GetGenericArguments().Map(x => x.AsFriendlyName(feature)); suffix = "<{0}>".Fmt(string.Join(",", args.ToArray())); } string frindlyName; return feature.FriendlyTypeNames.TryGetValue(typeName, out frindlyName) ? frindlyName + suffix : typeName + suffix; }
public string GetName(PostmanFeature feature, Postman request, Type requestType, string virtualPath) { var fragments = request.Label ?? feature.DefaultLabelFmt; var sb = new StringBuilder(); foreach (var fragment in fragments) { var parts = fragment.ToLower().Split(':'); var asEnglish = parts.Length > 1 && parts[1] == "english"; if (parts[0] == "type") { sb.Append(asEnglish ? requestType.Name.ToEnglish() : requestType.Name); } else if (parts[0] == "route") { sb.Append(virtualPath); } else { sb.Append(parts[0]); } } return sb.ToString(); }