aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Helpers
diff options
context:
space:
mode:
Diffstat (limited to 'Timeline/Helpers')
-rw-r--r--Timeline/Helpers/InvalidModelResponseFactory.cs1
-rw-r--r--Timeline/Helpers/LanguageHelper.cs12
-rw-r--r--Timeline/Helpers/Log.cs11
-rw-r--r--Timeline/Helpers/StringLocalizerFactoryExtensions.cs19
4 files changed, 37 insertions, 6 deletions
diff --git a/Timeline/Helpers/InvalidModelResponseFactory.cs b/Timeline/Helpers/InvalidModelResponseFactory.cs
index c792e845..643c99ac 100644
--- a/Timeline/Helpers/InvalidModelResponseFactory.cs
+++ b/Timeline/Helpers/InvalidModelResponseFactory.cs
@@ -6,6 +6,7 @@ namespace Timeline.Helpers
{
public static class InvalidModelResponseFactory
{
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1062:Validate arguments of public methods")]
public static IActionResult Factory(ActionContext context)
{
var modelState = context.ModelState;
diff --git a/Timeline/Helpers/LanguageHelper.cs b/Timeline/Helpers/LanguageHelper.cs
new file mode 100644
index 00000000..b0156b8b
--- /dev/null
+++ b/Timeline/Helpers/LanguageHelper.cs
@@ -0,0 +1,12 @@
+using System.Linq;
+
+namespace Timeline.Helpers
+{
+ public static class LanguageHelper
+ {
+ public static bool AreSame(this bool firstBool, params bool[] otherBools)
+ {
+ return otherBools.All(b => b == firstBool);
+ }
+ }
+}
diff --git a/Timeline/Helpers/Log.cs b/Timeline/Helpers/Log.cs
index 123e8a8e..68c975fa 100644
--- a/Timeline/Helpers/Log.cs
+++ b/Timeline/Helpers/Log.cs
@@ -3,20 +3,19 @@ using System.Text;
namespace Timeline.Helpers
{
- public static class MyLogHelper
+ public static class Log
{
- public static KeyValuePair<string, object> Pair(string key, object value) => new KeyValuePair<string, object>(key, value);
-
- public static string FormatLogMessage(string summary, params KeyValuePair<string, object>[] properties)
+ public static string Format(string summary, params (string, object?)[] properties)
{
var builder = new StringBuilder();
builder.Append(summary);
foreach (var property in properties)
{
+ var (key, value) = property;
builder.AppendLine();
- builder.Append(property.Key);
+ builder.Append(key);
builder.Append(" : ");
- builder.Append(property.Value);
+ builder.Append(value);
}
return builder.ToString();
}
diff --git a/Timeline/Helpers/StringLocalizerFactoryExtensions.cs b/Timeline/Helpers/StringLocalizerFactoryExtensions.cs
new file mode 100644
index 00000000..c2252b2c
--- /dev/null
+++ b/Timeline/Helpers/StringLocalizerFactoryExtensions.cs
@@ -0,0 +1,19 @@
+
+using Microsoft.Extensions.Localization;
+using System.Reflection;
+
+namespace Timeline.Helpers
+{
+ internal static class StringLocalizerFactoryExtensions
+ {
+ internal static IStringLocalizer Create(this IStringLocalizerFactory factory, string basename)
+ {
+ return factory.Create(basename, new AssemblyName(typeof(StringLocalizerFactoryExtensions).Assembly.FullName!).Name);
+ }
+
+ internal static StringLocalizer<T> Create<T>(this IStringLocalizerFactory factory)
+ {
+ return new StringLocalizer<T>(factory);
+ }
+ }
+} \ No newline at end of file