many fixes

This commit is contained in:
Leonid Pershin
2025-10-16 07:11:30 +03:00
parent 0007a0ffc4
commit 7a3a0172cf
56 changed files with 2202 additions and 1258 deletions

View File

@@ -0,0 +1,39 @@
namespace ChatBot.Common.Results
{
/// <summary>
/// Represents the result of an operation that can succeed or fail
/// </summary>
public class Result
{
public bool IsSuccess { get; }
public string Error { get; }
protected Result(bool isSuccess, string error)
{
IsSuccess = isSuccess;
Error = error;
}
public static Result Success() => new(true, string.Empty);
public static Result Failure(string error) => new(false, error);
}
/// <summary>
/// Represents the result of an operation that returns a value
/// </summary>
public class Result<T> : Result
{
public T? Value { get; }
private Result(T? value, bool isSuccess, string error)
: base(isSuccess, error)
{
Value = value;
}
public static Result<T> Success(T value) => new(value, true, string.Empty);
public static new Result<T> Failure(string error) => new(default, false, error);
}
}