Überarbeite Methodennamen in der DTOExtensions-Klasse für Klarheit und Konsistenz.
This commit is contained in:
parent
f72b6f26f3
commit
f5c0a76f30
@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
namespace DigitalData.Core.DTO
|
||||
@ -62,28 +63,31 @@ namespace DigitalData.Core.DTO
|
||||
return result;
|
||||
}
|
||||
|
||||
public static I Then<I>(this Result result, Func<I> Try, Func<List<string>, List<Notice>, I> Catch)
|
||||
public static I Then<I>(this Result result, Func<I> Success, Func<List<string>, List<Notice>, I> Fail)
|
||||
{
|
||||
return result.IsSuccess ? Try() : Catch(result.Messages, result.Notices);
|
||||
return result.IsSuccess ? Success() : Fail(result.Messages, result.Notices);
|
||||
}
|
||||
|
||||
public static I Then<T, I>(this DataResult<T> result, Func<T, I> Try, Func<List<string>, List<Notice>, I> Catch)
|
||||
public static I Then<T, I>(this DataResult<T> result, Func<T, I> Success, Func<List<string>, List<Notice>, I> Fail)
|
||||
{
|
||||
return result.IsSuccess ? Try(result.Data) : Catch(result.Messages, result.Notices);
|
||||
return result.IsSuccess ? Success(result.Data) : Fail(result.Messages, result.Notices);
|
||||
}
|
||||
|
||||
public static async Task<I> ThenAsync<I>(this Task<Result> tResult, Func<I> Try, Func<List<string>, List<Notice>, I> Catch)
|
||||
public static async Task<I> ThenAsync<I>(this Task<Result> tResult, Func<I> Success, Func<List<string>, List<Notice>, I> Fail)
|
||||
{
|
||||
Result result = await tResult;
|
||||
return result.IsSuccess ? Try() : Catch(result.Messages, result.Notices);
|
||||
return result.IsSuccess ? Success() : Fail(result.Messages, result.Notices);
|
||||
}
|
||||
|
||||
public static async Task<I> ThenAsync<T, I>(this Task<DataResult<T>> tResult, Func<T, I> Try, Func<List<string>, List<Notice>, I> Catch)
|
||||
public static async Task<I> ThenAsync<T, I>(this Task<DataResult<T>> tResult, Func<T, I> Success, Func<List<string>, List<Notice>, I> Fail)
|
||||
{
|
||||
DataResult<T> result = await tResult;
|
||||
return result.IsSuccess ? Try(result.Data) : Catch(result.Messages, result.Notices);
|
||||
return result.IsSuccess ? Success(result.Data) : Fail(result.Messages, result.Notices);
|
||||
}
|
||||
|
||||
|
||||
public static string Join<T>(this IEnumerable<T> values, string start = "", string seperator = ". ", string end = ".")
|
||||
=> new StringBuilder(start).Append(string.Join(seperator, values)).Append(end).ToString();
|
||||
|
||||
public static void LogNotice(this ILogger logger, IEnumerable<Notice> notices, string start = ": ", string seperator = ". ", string end = ".\n")
|
||||
{
|
||||
foreach(LogLevel level in Enum.GetValues(typeof(LogLevel)))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user