1+ // ***********************************************************************
2+ // Assembly : RzR.Shared.Extensions.TryExecuteTests
3+ // Author : RzR
4+ // Created On : 2025-01-15 16:45
5+ //
6+ // Last Modified By : RzR
7+ // Last Modified On : 2025-01-20 19:34
8+ // ***********************************************************************
9+ // <copyright file="TestTryExecuteAbstrResultBase.cs" company="RzR SOFT & TECH">
10+ // Copyright © RzR. All rights reserved.
11+ // </copyright>
12+ //
13+ // <summary>
14+ // </summary>
15+ // ***********************************************************************
16+
17+ #region U S A G E S
18+
19+ using AggregatedGenericResultMessage . Abstractions ;
20+ using Microsoft . Extensions . Logging ;
21+ using System ;
22+ using System . Threading . Tasks ;
23+ // ReSharper disable RedundantLambdaParameterType
24+ // ReSharper disable UnusedParameter.Local
25+ // ReSharper disable NotAccessedField.Local
26+ // ReSharper disable RedundantArgumentDefaultValue
27+ #pragma warning disable CS0162
28+
29+ #endregion
30+
31+ namespace TryExecuteTests . Base
32+ {
33+ public abstract partial class TestTryExecuteAbstrBase
34+ {
35+ protected virtual async Task < IResult < TResult > > TryAsync < TResult > (
36+ Func < Task < IResult < TResult > > > execFunc ,
37+ Func < Exception , Task < IResult < TResult > > > onFailureResult )
38+ => await TryToExecuteAsync ( execFunc , onFailureResult , ( ) =>
39+ {
40+ execFunc = null ;
41+ onFailureResult = null ;
42+ } , false ) ;
43+
44+ protected virtual async Task < IResult < TResult > > TryAsync < TResult > (
45+ Func < Task < IResult < TResult > > > execFunc ,
46+ Func < Exception , IResult < TResult > > onFailureResult )
47+ => await TryToExecuteAsync ( execFunc , onFailureResult , ( ) =>
48+ {
49+ execFunc = null ;
50+ onFailureResult = null ;
51+ } , false ) ;
52+
53+ protected virtual async Task < IResult < TResult > > TryAsync < TResult , TLogger > (
54+ Func < Task < IResult < TResult > > > execFunc ,
55+ Func < IResult < TResult > > onFailureResult ,
56+ ILogger < TLogger > exceptionLogger )
57+ => await TryToExecuteAsync ( execFunc , onFailureResult , finallyExecAction : ( ) =>
58+ {
59+ execFunc = null ;
60+ onFailureResult = null ;
61+ exceptionLogger = null ;
62+ } , exceptionLogger : exceptionLogger , forceCallGarbageCollector : false ) ;
63+
64+ protected virtual async Task < IResult < TResult > > TryAsync < TResult , TLogger > (
65+ Func < Task < IResult < TResult > > > execFunc ,
66+ Func < Task < IResult < TResult > > > onFailureResult ,
67+ ILogger < TLogger > exceptionLogger )
68+ => await TryToExecuteAsync ( execFunc , onFailureResult , finallyExecAction : ( ) =>
69+ {
70+ execFunc = null ;
71+ onFailureResult = null ;
72+ exceptionLogger = null ;
73+ } , exceptionLogger : exceptionLogger , forceCallGarbageCollector : false ) ;
74+ }
75+ }
0 commit comments