-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
50 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
framework/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ApiTypeNameHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using Volo.Abp.Reflection; | ||
|
||
namespace Volo.Abp.Http.Modeling | ||
{ | ||
public static class ApiTypeNameHelper | ||
{ | ||
public static string GetTypeName(Type type) | ||
{ | ||
if (TypeHelper.IsDictionary(type, out var keyType, out var valueType)) | ||
{ | ||
return $"{{{GetTypeName(keyType)}:{GetTypeName(valueType)}}}"; | ||
} | ||
|
||
if (TypeHelper.IsEnumerable(type, out var itemType, includePrimitives: false)) | ||
{ | ||
return $"[{GetTypeName(itemType)}]"; | ||
} | ||
|
||
return TypeHelper.GetFullNameHandlingNullableAndGenerics(type); | ||
} | ||
|
||
public static string GetSimpleTypeName(Type type) | ||
{ | ||
if (TypeHelper.IsDictionary(type, out var keyType, out var valueType)) | ||
{ | ||
return $"{{{GetSimpleTypeName(keyType)}:{GetSimpleTypeName(valueType)}}}"; | ||
} | ||
|
||
if (TypeHelper.IsEnumerable(type, out var itemType, includePrimitives: false)) | ||
{ | ||
return $"[{GetSimpleTypeName(itemType)}]"; | ||
} | ||
|
||
return TypeHelper.GetSimplifiedName(type); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters