Added new module for cpp compatibility

This commit is contained in:
2024-09-19 13:44:05 +03:00
parent be75ef03cb
commit 49403e70fd
10 changed files with 393 additions and 1 deletions

View File

@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace DiscordBotCore.Others;
public class JsonManager
public static class JsonManager
{
/// <summary>
/// Save to JSON file

View File

@@ -19,6 +19,18 @@ public class Result
_Result = result;
Exception = null;
}
public bool IsSuccess => _Result.HasValue && _Result.Value;
public void HandleException(Action<Exception> action)
{
if(IsSuccess)
{
return;
}
action(Exception!);
}
public static Result Success() => new Result(true);
public static Result Failure(Exception ex) => new Result(ex);
@@ -36,6 +48,12 @@ public class Result
}
}
public TResult Match<TResult>(Func<TResult> successAction, Func<Exception,TResult> errorAction)
{
return IsSuccess ? successAction() : errorAction(Exception!);
}
}
public class Result<T>