fixes for the previous commit

This commit is contained in:
2021-12-12 16:38:08 +03:00
parent e9d490ebe3
commit 4ee8cd8d83
5 changed files with 30 additions and 5 deletions

24
Extensions/IfMethod.cs Normal file
View File

@@ -0,0 +1,24 @@
using System;
namespace DTLib.Extensions
{
public static class IfMethod
{
public static T If<T>(this T input, bool condition, Func<T, T> if_true, Func<T, T> if_false) =>
condition ? if_true(input) : if_false(input);
public static void If<T>(this T input, bool condition, Action<T> if_true, Action<T> if_false)
{
if (condition) if_true(input);
else if_false(input);
}
public static T If<T>(this T input, bool condition, Func<T, T> if_true) =>
condition ? if_true(input) : input;
public static void If<T>(this T input, bool condition, Action<T> if_true)
{
if (condition) if_true(input);
}
}
}

View File

@@ -3,7 +3,7 @@ using System.Text;
namespace DTLib.Extensions
{
public static class ToStringConverter
public static class StringConverter
{
public static Encoding UTF8 = new UTF8Encoding(false);
public static byte[] ToBytes(this string str) => UTF8.GetBytes(str);