fixes for the previous commit
This commit is contained in:
24
Extensions/IfMethod.cs
Normal file
24
Extensions/IfMethod.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
Reference in New Issue
Block a user