feat(dal): добавлено расширение string ApplyShortcode - позволяет подставлять в строковых переменные шаблонные значения типа %ЭК%

This commit is contained in:
Mikhail Kuznetsov
2024-03-20 15:26:14 +10:00
parent ff712ed126
commit b803f8beaa
6 changed files with 54 additions and 7 deletions

View File

@@ -1,4 +1,5 @@
using System.Text.Encodings.Web;
using PARR.Constants.Shortcode;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Unicode;
@@ -26,6 +27,8 @@ namespace PARR.DAL.Extensions
return null;
}
}
public static DateTimeOffset EndOfDay(this DateTimeOffset date)
{
return new DateTimeOffset(date.Year, date.Month, date.Day, 23, 59, 59, 999, new TimeSpan(0));
@@ -35,5 +38,19 @@ namespace PARR.DAL.Extensions
{
return new DateTimeOffset(date.Year, date.Month, date.Day, 0, 0, 0, 0, new TimeSpan(0));
}
/// <summary>
///
/// </summary>
/// <param name="sourceString">Исходная строка, включающая переменные части вида %ШАБЛОН%</param>
/// <param name="shortcode">Код шаблона из PARR.Constants.Shortcode.Shortcodes</param>
/// <param name="shortcodeValue">Итоговое строковое значение</param>
/// <returns></returns>
public static string ApplyShortcode(this string sourceString, Shortcodes shortcode, string shortcodeValue)
{
var shortcodeName = ShortcodeNames.GetShortcodeName(shortcode);
return sourceString.Replace(shortcodeName, shortcodeValue);
}
}
}