maliming
5 years ago
No known key found for this signature in database
GPG Key ID: 96224957E51C89E
14 changed files with
27 additions and
27 deletions
-
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/ValueConverters/AbpJsonValueConverter.cs
-
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/ValueConverters/ExtraPropertiesValueConverter.cs
-
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionFinder.cs
-
framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/AbpSystemTextJsonSerializerProvider.cs
-
framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToBooleanConverter.cs
-
framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumConverter.cs
-
framework/src/Volo.Abp.Localization/Volo/Abp/Localization/Json/JsonLocalizationDictionaryBuilder.cs
-
framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpStringToBoolean_Tests.cs
-
framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpStringToEnum_Tests.cs
-
framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/ExtensibleObject_Tests.cs
-
framework/test/Volo.Abp.MemoryDb.Tests/Volo/Abp/MemoryDb/JsonConverters/EntityJsonConverter.cs
-
modules/feature-management/src/Volo.Abp.FeatureManagement.Application.Contracts/Volo/Abp/FeatureManagement/JsonConverters/SelectionStringValueItemSourceJsonConverter.cs
-
modules/feature-management/src/Volo.Abp.FeatureManagement.Application.Contracts/Volo/Abp/FeatureManagement/JsonConverters/StringValueTypeJsonConverter.cs
-
modules/feature-management/src/Volo.Abp.FeatureManagement.Application.Contracts/Volo/Abp/FeatureManagement/JsonConverters/ValueValidatorJsonConverter.cs
|
|
|
@ -26,7 +26,7 @@ namespace Volo.Abp.EntityFrameworkCore.ValueConverters |
|
|
|
new ObjectToInferredTypesConverter() |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
private static TPropertyType DeserializeObject(string s) |
|
|
|
{ |
|
|
|
return JsonSerializer.Deserialize<TPropertyType>(s, DeserializeOptions); |
|
|
|
|
|
|
|
@ -48,14 +48,14 @@ namespace Volo.Abp.EntityFrameworkCore.ValueConverters |
|
|
|
new ObjectToInferredTypesConverter() |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
private static ExtraPropertyDictionary DeserializeObject(string extraPropertiesAsJson, Type entityType) |
|
|
|
{ |
|
|
|
if (extraPropertiesAsJson.IsNullOrEmpty() || extraPropertiesAsJson == "{}") |
|
|
|
{ |
|
|
|
return new ExtraPropertyDictionary(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var dictionary = JsonSerializer.Deserialize<ExtraPropertyDictionary>(extraPropertiesAsJson, DeserializeOptions) ?? |
|
|
|
new ExtraPropertyDictionary(); |
|
|
|
|
|
|
|
|
|
|
|
@ -94,7 +94,7 @@ namespace Volo.Abp.Http.Client.DynamicProxying |
|
|
|
{ |
|
|
|
PropertyNamingPolicy = JsonNamingPolicy.CamelCase |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
protected virtual async Task<ApplicationApiDescriptionModel> GetApiDescriptionFromServerAsync( |
|
|
|
HttpClient client, |
|
|
|
string baseUrl) |
|
|
|
|
|
|
|
@ -41,7 +41,7 @@ namespace Volo.Abp.Json.SystemTextJson |
|
|
|
} |
|
|
|
|
|
|
|
private readonly ConcurrentDictionary<string, JsonSerializerOptions> JsonSerializerOptionsCache = new ConcurrentDictionary<string, JsonSerializerOptions>(); |
|
|
|
|
|
|
|
|
|
|
|
protected virtual JsonSerializerOptions CreateJsonSerializerOptions(bool camelCase = true, bool indented = false) |
|
|
|
{ |
|
|
|
return JsonSerializerOptionsCache.GetOrAdd($"default{camelCase}{indented}", _ => |
|
|
|
|
|
|
|
@ -7,9 +7,9 @@ using System.Text.Json.Serialization; |
|
|
|
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) |
|
|
|
@ -33,7 +33,7 @@ namespace Volo.Abp.Json.SystemTextJson.JsonConverters |
|
|
|
{ |
|
|
|
_writeJsonSerializerOptions ??= JsonSerializerOptionsHelper.Create(options, this); |
|
|
|
var entityConverter = (JsonConverter<bool>)_writeJsonSerializerOptions.GetConverter(typeof(bool)); |
|
|
|
|
|
|
|
|
|
|
|
entityConverter.Write(writer, value, _writeJsonSerializerOptions); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -11,9 +11,9 @@ namespace Volo.Abp.Json.SystemTextJson.JsonConverters |
|
|
|
private readonly JsonStringEnumConverter _innerJsonStringEnumConverter; |
|
|
|
|
|
|
|
private JsonSerializerOptions _readJsonSerializerOptions; |
|
|
|
|
|
|
|
|
|
|
|
private JsonSerializerOptions _writeJsonSerializerOptions; |
|
|
|
|
|
|
|
|
|
|
|
public AbpStringToEnumConverter() |
|
|
|
: this(namingPolicy: null, allowIntegerValues: true) |
|
|
|
{ |
|
|
|
|
|
|
|
@ -31,7 +31,7 @@ namespace Volo.Abp.Localization.Json |
|
|
|
ReadCommentHandling = JsonCommentHandling.Skip, |
|
|
|
AllowTrailingCommas = true |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Builds an <see cref="JsonLocalizationDictionaryBuilder" /> from given json string.
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
@ -21,12 +21,12 @@ namespace Volo.Abp.Json |
|
|
|
var testClass = JsonSerializer.Deserialize<TestClass>("{\"Enabled\": \"TrUe\"}", options); |
|
|
|
testClass.ShouldNotBeNull(); |
|
|
|
testClass.Enabled.ShouldBe(true); |
|
|
|
|
|
|
|
|
|
|
|
testClass = JsonSerializer.Deserialize<TestClass>("{\"Enabled\": true}", options); |
|
|
|
testClass.ShouldNotBeNull(); |
|
|
|
testClass.Enabled.ShouldBe(true); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Test_Write() |
|
|
|
{ |
|
|
|
@ -42,7 +42,7 @@ namespace Volo.Abp.Json |
|
|
|
{ |
|
|
|
Enabled = true |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
testClassJson.ShouldBe("{\"Enabled\":true}"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -22,12 +22,12 @@ namespace Volo.Abp.Json |
|
|
|
var testClass = JsonSerializer.Deserialize<TestClass>("{\"Day\": \"Monday\"}", options); |
|
|
|
testClass.ShouldNotBeNull(); |
|
|
|
testClass.Day.ShouldBe(DayOfWeek.Monday); |
|
|
|
|
|
|
|
|
|
|
|
testClass = JsonSerializer.Deserialize<TestClass>("{\"Day\": 1}", options); |
|
|
|
testClass.ShouldNotBeNull(); |
|
|
|
testClass.Day.ShouldBe(DayOfWeek.Monday); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Test_Write() |
|
|
|
{ |
|
|
|
@ -43,7 +43,7 @@ namespace Volo.Abp.Json |
|
|
|
{ |
|
|
|
Day = DayOfWeek.Monday |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
testClassJson.ShouldBe("{\"Day\":1}"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -60,7 +60,7 @@ namespace Volo.Abp.Json |
|
|
|
fooDto.BarDtos.First().Name.ShouldBe("new-bar-dto"); |
|
|
|
fooDto.BarDtos.First().GetProperty("bar").ShouldBe("new-bar-value"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void SelfReference_Test() |
|
|
|
{ |
|
|
|
@ -100,14 +100,14 @@ namespace Volo.Abp.Json |
|
|
|
class BarDto : ExtensibleObject |
|
|
|
{ |
|
|
|
public string Name { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
public FooDto FooDto { get; set; } |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class NodeDto : ExtensibleObject |
|
|
|
{ |
|
|
|
public string Name { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
public NodeDto Parent { get; set; } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -9,7 +9,7 @@ namespace Volo.Abp.MemoryDb.JsonConverters |
|
|
|
where TEntity : Entity<TKey> |
|
|
|
{ |
|
|
|
private JsonSerializerOptions _writeJsonSerializerOptions; |
|
|
|
|
|
|
|
|
|
|
|
public override TEntity Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) |
|
|
|
{ |
|
|
|
var jsonDocument = JsonDocument.ParseValue(ref reader); |
|
|
|
|
|
|
|
@ -9,7 +9,7 @@ namespace Volo.Abp.FeatureManagement.JsonConverters |
|
|
|
public class SelectionStringValueItemSourceJsonConverter : JsonConverter<ISelectionStringValueItemSource> |
|
|
|
{ |
|
|
|
private JsonSerializerOptions _readJsonSerializerOptions; |
|
|
|
|
|
|
|
|
|
|
|
private JsonSerializerOptions _writeJsonSerializerOptions; |
|
|
|
|
|
|
|
public override ISelectionStringValueItemSource Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) |
|
|
|
|
|
|
|
@ -9,9 +9,9 @@ namespace Volo.Abp.FeatureManagement.JsonConverters |
|
|
|
public class StringValueTypeJsonConverter : JsonConverter<IStringValueType> |
|
|
|
{ |
|
|
|
private JsonSerializerOptions _readJsonSerializerOptions; |
|
|
|
|
|
|
|
|
|
|
|
private JsonSerializerOptions _writeJsonSerializerOptions; |
|
|
|
|
|
|
|
|
|
|
|
public override IStringValueType Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) |
|
|
|
{ |
|
|
|
var rootElement = JsonDocument.ParseValue(ref reader).RootElement; |
|
|
|
|
|
|
|
@ -11,9 +11,9 @@ namespace Volo.Abp.FeatureManagement.JsonConverters |
|
|
|
public class ValueValidatorJsonConverter : JsonConverter<IValueValidator> |
|
|
|
{ |
|
|
|
private JsonSerializerOptions _readJsonSerializerOptions; |
|
|
|
|
|
|
|
|
|
|
|
private JsonSerializerOptions _writeJsonSerializerOptions; |
|
|
|
|
|
|
|
|
|
|
|
public override IValueValidator Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) |
|
|
|
{ |
|
|
|
var rootElement = JsonDocument.ParseValue(ref reader).RootElement; |
|
|
|
|