mirror of https://github.com/abpframework/abp.git
3 changed files with 33 additions and 26 deletions
@ -0,0 +1,32 @@ |
|||||
|
using System; |
||||
|
using System.Reflection; |
||||
|
|
||||
|
namespace Volo.Abp.Http.ProxyScripting.Configuration |
||||
|
{ |
||||
|
public static class AbpApiPropertyNameConfiguration |
||||
|
{ |
||||
|
public static Func<PropertyInfo, string> PropertyNameGenerator { get; set; } |
||||
|
|
||||
|
static AbpApiPropertyNameConfiguration() |
||||
|
{ |
||||
|
PropertyNameGenerator = propertyInfo => |
||||
|
{ |
||||
|
var jsonPropertyNameAttribute = propertyInfo.GetSingleAttributeOrNull<System.Text.Json.Serialization.JsonPropertyNameAttribute>(true); |
||||
|
|
||||
|
if (jsonPropertyNameAttribute != null) |
||||
|
{ |
||||
|
return jsonPropertyNameAttribute.Name; |
||||
|
} |
||||
|
|
||||
|
var jsonPropertyAttribute = propertyInfo.GetSingleAttributeOrNull<Newtonsoft.Json.JsonPropertyAttribute>(true); |
||||
|
|
||||
|
if (jsonPropertyAttribute != null) |
||||
|
{ |
||||
|
return jsonPropertyAttribute.PropertyName; |
||||
|
} |
||||
|
|
||||
|
return null; |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue