Доработка метода получения словаря
All checks were successful
Unit tests / test (push) Successful in 49s

This commit is contained in:
Alex Shibalkin 2025-01-16 17:32:03 +05:00
parent e50bd64be1
commit d5942cd670
3 changed files with 13 additions and 11 deletions

View File

@ -4,6 +4,7 @@ using DD.Persistence.Client.Clients.Interfaces;
using DD.Persistence.Client.Clients.Interfaces.Refit;
using DD.Persistence.Models;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace DD.Persistence.Client.Clients;
@ -11,7 +12,7 @@ public class SetpointClient : BaseClient, ISetpointClient
{
private readonly IRefitSetpointClient refitSetpointClient;
public SetpointClient(IRefitClientFactory<IRefitSetpointClient> refitSetpointClientFactory, ILogger<SetpointClient> logger) : base(logger)
public SetpointClient(IRefitClientFactory<IRefitSetpointClient> refitSetpointClientFactory, ILogger<SetpointClient> logger) : base(logger)
{
this.refitSetpointClient = refitSetpointClientFactory.Create();
}
@ -32,19 +33,20 @@ public class SetpointClient : BaseClient, ISetpointClient
return dict;
}
private static Dictionary<Guid, object?> DeserializeResultToDict(Dictionary<Guid, Type> setpointConfigs, IEnumerable<SetpointValueDto> data)
{
var dict = new Dictionary<Guid, object?>();
foreach (var valueDto in data)
{
if (valueDto.Value is not null &&
valueDto.Value is JsonElement element &&
setpointConfigs.TryGetValue(valueDto.Key, out var type) &&
type is not null)
dict[valueDto.Key] = element.Deserialize(type!) ?? valueDto.Value;
dict[valueDto.Key] = Convert.ChangeType(element.GetString(), type) ?? valueDto.Value;
else
dict[valueDto.Key] = valueDto.Value;
}

View File

@ -11,9 +11,9 @@
<!--Наименование-->
<Title>DD.Persistence.Client</Title>
<!--Версия пакета-->
<VersionPrefix>1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH))</VersionPrefix>
<VersionPrefix>1.1.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH)).1</VersionPrefix>
<!--Версия сборки-->
<AssemblyVersion>1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH))</AssemblyVersion>
<AssemblyVersion>1.1.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH)).1</AssemblyVersion>
<!--Id пакета-->
<PackageId>DD.Persistence.Client</PackageId>
@ -33,15 +33,15 @@
<!--Формат пакета с символами-->
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<!--Путь к пакету-->
<PackageOutputPath>C:\Projects\Nuget\Persistence\Client</PackageOutputPath>
<PackageOutputPath>C:\Projects\Nuget\Persistence</PackageOutputPath>
<!--Readme-->
<PackageReadmeFile>Readme.md</PackageReadmeFile>
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH))</VersionPrefix>
<AssemblyVersion>1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH))</AssemblyVersion>
<VersionPrefix>1.2.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH))</VersionPrefix>
<AssemblyVersion>1.2.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH))</AssemblyVersion>
</PropertyGroup>
<ItemGroup>

View File

@ -11,9 +11,9 @@
<!--Наименование-->
<Title>DD.Persistence.Models</Title>
<!--Версия пакета-->
<VersionPrefix>1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH))</VersionPrefix>
<VersionPrefix>1.1.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH))</VersionPrefix>
<!--Версия сборки-->
<AssemblyVersion>1.0.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH))</AssemblyVersion>
<AssemblyVersion>1.1.$([System.DateTime]::UtcNow.ToString(yyMM.ddHH))</AssemblyVersion>
<!--Id пакета-->
<PackageId>DD.Persistence.Models</PackageId>
@ -33,7 +33,7 @@
<!--Формат пакета с символами-->
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<!--Путь к пакету-->
<PackageOutputPath>C:\Projects\Nuget\Persistence\Models</PackageOutputPath>
<PackageOutputPath>C:\Projects\Nuget\Persistence</PackageOutputPath>
</PropertyGroup>
<ItemGroup>