From 3c54d7ee8f10164d25ace9ea8872a8eaba0d2d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0smail=20=C3=87A=C4=9EDA=C5=9E?= Date: Wed, 27 Jul 2022 17:37:10 +0300 Subject: [PATCH 1/4] Rename angular.md to Angular.md --- docs/en/Themes/LeptonXLite/{angular.md => Angular.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/en/Themes/LeptonXLite/{angular.md => Angular.md} (100%) diff --git a/docs/en/Themes/LeptonXLite/angular.md b/docs/en/Themes/LeptonXLite/Angular.md similarity index 100% rename from docs/en/Themes/LeptonXLite/angular.md rename to docs/en/Themes/LeptonXLite/Angular.md From 3ad8426a95f430fb751abe2790179fac6e652e8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0smail=20=C3=87A=C4=9EDA=C5=9E?= Date: Wed, 27 Jul 2022 17:37:25 +0300 Subject: [PATCH 2/4] Rename blazor.md to Blazor.md --- docs/en/Themes/LeptonXLite/{blazor.md => Blazor.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/en/Themes/LeptonXLite/{blazor.md => Blazor.md} (100%) diff --git a/docs/en/Themes/LeptonXLite/blazor.md b/docs/en/Themes/LeptonXLite/Blazor.md similarity index 100% rename from docs/en/Themes/LeptonXLite/blazor.md rename to docs/en/Themes/LeptonXLite/Blazor.md From 8942171a63961e42cd623def834c3da26613d508 Mon Sep 17 00:00:00 2001 From: Engincan VESKE <43685404+EngincanV@users.noreply.github.com> Date: Tue, 2 Aug 2022 16:17:10 +0300 Subject: [PATCH 3/4] Update Config-State-Service.md --- docs/en/UI/Angular/Config-State-Service.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/UI/Angular/Config-State-Service.md b/docs/en/UI/Angular/Config-State-Service.md index 11415eb771..c457184fc2 100644 --- a/docs/en/UI/Angular/Config-State-Service.md +++ b/docs/en/UI/Angular/Config-State-Service.md @@ -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 => { From ea56f65501e9c4eb080b7313b9182f67f20c4653 Mon Sep 17 00:00:00 2001 From: maliming Date: Thu, 4 Aug 2022 21:53:29 +0800 Subject: [PATCH 4/4] Support `enum` as dictionary keys. Resolve #13552 --- .../JsonConverters/AbpStringToEnumConverter.cs | 11 ++++++++++- .../Volo/Abp/Json/AbpStringToEnum_Tests.cs | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumConverter.cs b/framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumConverter.cs index c4720c92db..6b7f32807e 100644 --- a/framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumConverter.cs +++ b/framework/src/Volo.Abp.Json/Volo/Abp/Json/SystemTextJson/JsonConverters/AbpStringToEnumConverter.cs @@ -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 : JsonConverter 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)); + } } diff --git a/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpStringToEnum_Tests.cs b/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpStringToEnum_Tests.cs index d3bba36534..8336b4ce7d 100644 --- a/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpStringToEnum_Tests.cs +++ b/framework/test/Volo.Abp.Json.Tests/Volo/Abp/Json/AbpStringToEnum_Tests.cs @@ -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("{\"Day\": 1}", options); testClass.ShouldNotBeNull(); testClass.Day.ShouldBe(DayOfWeek.Monday); + + var dictionary = JsonSerializer.Deserialize>("{\"Monday\":\"Mo\"}", options); + dictionary.ShouldNotBeNull(); + dictionary.Keys.ShouldContain(DayOfWeek.Monday); + dictionary.Values.ShouldContain("Mo"); + + dictionary = JsonSerializer.Deserialize>("{\"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.Monday, "Mo"} + }, options); + + testClassJson.ShouldBe("{\"Monday\":\"Mo\"}"); } class TestClass