Browse Source
Merge pull request #17148 from abpframework/auto-merge/rel-7-3/2078
Merge branch dev with rel-7.3
pull/17156/head
maliming
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
13 additions and
30 deletions
docs/en/Features.md
framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpNullableStringToGuidConverter.cs
framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToBooleanConverter.cs
framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumConverter.cs
framework/src/Volo.Abp.Json.SystemTextJson/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToGuidConverter.cs
framework/test/Volo.Abp.MemoryDb.Tests/Volo/Abp/MemoryDb/JsonConverters/EntityJsonConverter.cs
@ -32,7 +32,7 @@ public class ReportingAppService : ApplicationService, IReportingAppService
* `RequiresFeature(...)` simply gets a feature name to check if it is enabled or not. If not enabled, an authorization [exception ](Exception-Handling.md ) is thrown and a proper response is returned to the client side.
* `[RequiresFeature]` can be used for a **method** or a **class** . When you use it for a class, all the methods of that class require the given feature.
* `RequiresFeature` may get multiple feature names, like `[RequiresFeature("Feature1", "Feature2")]` . In this case ABP checks if any of the features enabled. Use `RequiresAll` option, like `[RequiresFeature("Feature1", "Feature2", RequiresAll = true)]` to force to check all of the features to be enabled.
* Multiple usage of `[RequiresFeature]` attribute is supported for a method or class. ABP check check s all of them in that case.
* Multiple usage of `[RequiresFeature]` attribute is supported for a method or class. ABP checks all of them in that case.
> Feature name can be any arbitrary string. It should be unique for a feature.
@ -6,8 +6,6 @@ namespace Volo.Abp.Json.SystemTextJson.JsonConverters;
public class AbpNullableStringToGuidConverter : JsonConverter < Guid ? >
{
private JsonSerializerOptions ? _ writeJsonSerializerOptions ;
public override Guid ? Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions options )
{
if ( reader . TokenType = = JsonTokenType . String )
@ -33,9 +31,13 @@ public class AbpNullableStringToGuidConverter : JsonConverter<Guid?>
public override void Write ( Utf8JsonWriter writer , Guid ? value , JsonSerializerOptions options )
{
_ writeJsonSerializerOptions ? ? = JsonSerializerOptionsHelper . Create ( options , this ) ;
var entityConverter = ( JsonConverter < Guid ? > ) _ writeJsonSerializerOptions . GetConverter ( typeof ( Guid ? ) ) ;
entityConverter . Write ( writer , value , _ writeJsonSerializerOptions ) ;
if ( value = = null )
{
writer . WriteNullValue ( ) ;
}
else
{
writer . WriteStringValue ( value . Value ) ;
}
}
}
@ -8,8 +8,6 @@ namespace Volo.Abp.Json.SystemTextJson.JsonConverters;
public class AbpStringToBooleanConverter : JsonConverter < bool >
{
private JsonSerializerOptions ? _ writeJsonSerializerOptions ;
public override bool Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions options )
{
if ( reader . TokenType = = JsonTokenType . String )
@ -31,9 +29,6 @@ public class AbpStringToBooleanConverter : JsonConverter<bool>
public override void Write ( Utf8JsonWriter writer , bool value , JsonSerializerOptions options )
{
_ writeJsonSerializerOptions ? ? = JsonSerializerOptionsHelper . Create ( options , this ) ;
var entityConverter = ( JsonConverter < bool > ) _ writeJsonSerializerOptions . GetConverter ( typeof ( bool ) ) ;
entityConverter . Write ( writer , value , _ writeJsonSerializerOptions ) ;
writer . WriteBooleanValue ( value ) ;
}
}
@ -11,8 +11,6 @@ public class AbpStringToEnumConverter<T> : JsonConverter<T>
private JsonSerializerOptions ? _ readJsonSerializerOptions ;
private JsonSerializerOptions ? _ writeJsonSerializerOptions ;
public AbpStringToEnumConverter ( )
: this ( namingPolicy : null , allowIntegerValues : true )
{
@ -41,11 +39,7 @@ public class AbpStringToEnumConverter<T> : JsonConverter<T>
public override void Write ( Utf8JsonWriter writer , T value , JsonSerializerOptions options )
{
_ writeJsonSerializerOptions ? ? = JsonSerializerOptionsHelper . Create ( options , x = >
x = = this | |
x . GetType ( ) = = typeof ( AbpStringToEnumFactory ) ) ;
JsonSerializer . Serialize ( writer , value , _ writeJsonSerializerOptions ) ;
JsonSerializer . Serialize ( writer , value ) ;
}
public override T ReadAsPropertyName ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions options )
@ -6,8 +6,6 @@ namespace Volo.Abp.Json.SystemTextJson.JsonConverters;
public class AbpStringToGuidConverter : JsonConverter < Guid >
{
private JsonSerializerOptions ? _ writeJsonSerializerOptions ;
public override Guid Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions options )
{
if ( reader . TokenType = = JsonTokenType . String )
@ -28,9 +26,6 @@ public class AbpStringToGuidConverter : JsonConverter<Guid>
public override void Write ( Utf8JsonWriter writer , Guid value , JsonSerializerOptions options )
{
_ writeJsonSerializerOptions ? ? = JsonSerializerOptionsHelper . Create ( options , this ) ;
var entityConverter = ( JsonConverter < Guid > ) _ writeJsonSerializerOptions . GetConverter ( typeof ( Guid ) ) ;
entityConverter . Write ( writer , value , _ writeJsonSerializerOptions ) ;
writer . WriteStringValue ( value ) ;
}
}
@ -8,8 +8,6 @@ namespace Volo.Abp.MemoryDb.JsonConverters;
public class EntityJsonConverter < TEntity , TKey > : JsonConverter < TEntity >
where TEntity : Entity < TKey >
{
private JsonSerializerOptions _ writeJsonSerializerOptions ;
public override TEntity Read ( ref Utf8JsonReader reader , Type typeToConvert , JsonSerializerOptions options )
{
var jsonDocument = JsonDocument . ParseValue ( ref reader ) ;
@ -34,7 +32,6 @@ public class EntityJsonConverter<TEntity, TKey> : JsonConverter<TEntity>
public override void Write ( Utf8JsonWriter writer , TEntity value , JsonSerializerOptions options )
{
_ writeJsonSerializerOptions ? ? = JsonSerializerOptionsHelper . Create ( options , this ) ;
JsonSerializer . Serialize ( writer , value , _ writeJsonSerializerOptions ) ;
JsonSerializer . Serialize ( writer , value , JsonSerializerOptionsHelper . Create ( options , this ) ) ;
}
}