feat(dal): добавлено расширение string ApplyShortcode - позволяет подставлять в строковых переменные шаблонные значения типа %ЭК%
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user