From 5872049cc7bac2e9d58d57518ce93a6cd4e65dcf Mon Sep 17 00:00:00 2001 From: Alexander Date: Fri, 28 Oct 2022 10:02:17 +0300 Subject: [PATCH] 20221028 --- anbs_cp/TypeConverter.cs | 29 +++++++++++++++++++++- anbs_cp/anbs_cp.csproj | 11 ++++---- anbsoftware.componentspack.sln.DotSettings | 3 ++- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/anbs_cp/TypeConverter.cs b/anbs_cp/TypeConverter.cs index c1205eb..2f988e7 100644 --- a/anbs_cp/TypeConverter.cs +++ b/anbs_cp/TypeConverter.cs @@ -1,4 +1,7 @@ -namespace anbs_cp; +using System.Text.Encodings.Web; +using Microsoft.AspNetCore.Html; + +namespace anbs_cp; /// /// Конвертер типов на манер Delphi @@ -107,4 +110,28 @@ public static class TypeConverter } #endregion + + #region Конвернтация IHtmlContent + /// + /// Преобразует тип в строку . + /// + /// Значение, которое нужно преобразовать. + /// + public static string HtmlContentToString (IHtmlContent content) + { + //Создаём writer + using StringWriter writer = new(); + //Конвертируем IHtmlContent в string + content.WriteTo(writer, HtmlEncoder.Default); + //Возвращаем результат + return writer.ToString(); + } + + /// + /// Преобразует строку в тип . + /// + /// Значение, которое нужно преобразовать. + /// + public static IHtmlContent StringToHtmlContent(string content) => new HtmlContentBuilder().AppendHtml(content); + #endregion } \ No newline at end of file diff --git a/anbs_cp/anbs_cp.csproj b/anbs_cp/anbs_cp.csproj index 58b5ff9..95deaa4 100644 --- a/anbs_cp/anbs_cp.csproj +++ b/anbs_cp/anbs_cp.csproj @@ -2,7 +2,7 @@ net6.0 - 1.2022.723 + 1.2022.1028 Alexander Babaev ANB Software Components Pack Library of some useful functions in C# language. @@ -13,10 +13,10 @@ enable True False - https://github.com/GoodBoyAlex/anbsoftware_componentspack - https://github.com/GoodBoyAlex/anbsoftware_componentspack - 1.2022.723 - 1.2022.723 + https://git.babaev-an.ru/babaev-an/anbsoftware_componentspack + https://git.babaev-an.ru/babaev-an/anbsoftware_componentspack + 1.2022.1028 + 1.2022.1028 ANBSoftware.ComponentsPack MIT 6.0 @@ -33,6 +33,7 @@ + diff --git a/anbsoftware.componentspack.sln.DotSettings b/anbsoftware.componentspack.sln.DotSettings index acbae49..5d94243 100644 --- a/anbsoftware.componentspack.sln.DotSettings +++ b/anbsoftware.componentspack.sln.DotSettings @@ -1,4 +1,5 @@  True True - True \ No newline at end of file + True + True \ No newline at end of file