Вроде все ошибки устранил. не запускал.
This commit is contained in:
30
PARR.DAL/Extensions/GeneralExtesions.cs
Normal file
30
PARR.DAL/Extensions/GeneralExtesions.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Text.Encodings.Web;
|
||||
using System.Text.Json;
|
||||
using System.Text.Unicode;
|
||||
|
||||
namespace PARR.DAL.Extensions
|
||||
{
|
||||
public static class GeneralExtesions
|
||||
{
|
||||
/// <summary>
|
||||
/// Преобразует объект в Json, с учетом Cyrillic
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static string? ToJson(this object value)
|
||||
{
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
try
|
||||
{
|
||||
return JsonSerializer.Serialize(value, new JsonSerializerOptions { Encoder = JavaScriptEncoder.Create(UnicodeRanges.All, UnicodeRanges.Cyrillic) }); ;
|
||||
}
|
||||
catch// (Exception ex)
|
||||
{
|
||||
// todo: писать лог??? или и так пойдет
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user