Browse Source
Merge pull request #13569 from abpframework/auto-merge/rel-5-3/1247
Merge branch rel-6.0 with rel-5.3
pull/13570/head
liangshiwei
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
29 additions and
2 deletions
-
docs/en/Themes/LeptonXLite/Angular.md
-
docs/en/Themes/LeptonXLite/Blazor.md
-
docs/en/UI/Angular/Config-State-Service.md
-
framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumConverter.cs
-
framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpStringToEnum_Tests.cs
|
|
|
@ -120,7 +120,7 @@ Please refer to `ApplicationConfigurationDto` type for all the properties you ca |
|
|
|
You can get the application configuration response and set the `ConfigStateService` state value as shown below: |
|
|
|
|
|
|
|
```js |
|
|
|
import {ApplicationConfigurationService, ConfigStateService} from '@abp/ng.core'; |
|
|
|
import {AbpApplicationConfigurationService, ConfigStateService} from '@abp/ng.core'; |
|
|
|
|
|
|
|
constructor(private abpApplicationConfigurationService: AbpApplicationConfigurationService, private config: ConfigStateService) { |
|
|
|
this.abpApplicationConfigurationService.get().subscribe(config => { |
|
|
|
|
|
|
|
@ -1,5 +1,4 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Text.Json; |
|
|
|
using System.Text.Json.Serialization; |
|
|
|
|
|
|
|
@ -48,4 +47,14 @@ public class AbpStringToEnumConverter<T> : JsonConverter<T> |
|
|
|
|
|
|
|
JsonSerializer.Serialize(writer, value, _writeJsonSerializerOptions); |
|
|
|
} |
|
|
|
|
|
|
|
public override T ReadAsPropertyName(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) |
|
|
|
{ |
|
|
|
return (T)Enum.Parse(typeToConvert, reader.GetString()); |
|
|
|
} |
|
|
|
|
|
|
|
public override void WriteAsPropertyName(Utf8JsonWriter writer, T value, JsonSerializerOptions options) |
|
|
|
{ |
|
|
|
writer.WritePropertyName(Enum.GetName(typeof(T), value)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -1,4 +1,5 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Text.Json; |
|
|
|
using Shouldly; |
|
|
|
using Volo.Abp.Json.SystemTextJson.JsonConverters; |
|
|
|
@ -26,6 +27,16 @@ namespace Volo.Abp.Json |
|
|
|
testClass = JsonSerializer.Deserialize<TestClass>("{\"Day\": 1}", options); |
|
|
|
testClass.ShouldNotBeNull(); |
|
|
|
testClass.Day.ShouldBe(DayOfWeek.Monday); |
|
|
|
|
|
|
|
var dictionary = JsonSerializer.Deserialize<Dictionary<DayOfWeek, string>>("{\"Monday\":\"Mo\"}", options); |
|
|
|
dictionary.ShouldNotBeNull(); |
|
|
|
dictionary.Keys.ShouldContain(DayOfWeek.Monday); |
|
|
|
dictionary.Values.ShouldContain("Mo"); |
|
|
|
|
|
|
|
dictionary = JsonSerializer.Deserialize<Dictionary<DayOfWeek, string>>("{\"1\":\"Mo\"}", options); |
|
|
|
dictionary.ShouldNotBeNull(); |
|
|
|
dictionary.Keys.ShouldContain(DayOfWeek.Monday); |
|
|
|
dictionary.Values.ShouldContain("Mo"); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
@ -45,6 +56,13 @@ namespace Volo.Abp.Json |
|
|
|
}); |
|
|
|
|
|
|
|
testClassJson.ShouldBe("{\"Day\":1}"); |
|
|
|
|
|
|
|
testClassJson = JsonSerializer.Serialize(new Dictionary<DayOfWeek, string> |
|
|
|
{ |
|
|
|
{DayOfWeek.Monday, "Mo"} |
|
|
|
}, options); |
|
|
|
|
|
|
|
testClassJson.ShouldBe("{\"Monday\":\"Mo\"}"); |
|
|
|
} |
|
|
|
|
|
|
|
class TestClass |
|
|
|
|