File tree Expand file tree Collapse file tree
ManagedCode.Communication Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44
55namespace ManagedCode . Communication ;
66
7- public abstract class BaseResult < TErrorCode > where TErrorCode : Enum
8- {
9- protected BaseResult ( bool isSuccess )
10- {
11- IsSuccess = isSuccess ;
12- }
13-
14- protected BaseResult ( Error < TErrorCode > error )
15- {
16- IsSuccess = false ;
17- Errors = new List < Error < TErrorCode > > { error } ;
18- }
19-
20- protected BaseResult ( List < Error < TErrorCode > > errors )
21- {
22- IsSuccess = false ;
23- Errors = errors ;
24- }
25-
26- protected BaseResult ( bool isSuccess , List < Error < TErrorCode > > errors )
27- {
28- IsSuccess = isSuccess ;
29- Errors = errors ;
30- }
31-
32- public bool IsSuccess { get ; }
33- public bool IsFail => ! IsSuccess ;
34- public Error < TErrorCode > ? Error => Errors ? . FirstOrDefault ( ) ;
35- public List < Error < TErrorCode > > ? Errors { get ; }
36- }
37-
387public abstract class BaseResult < T , TErrorCode > : BaseResult < TErrorCode > where TErrorCode : Enum
398{
409 protected BaseResult ( T value ) : base ( true )
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Collections . Generic ;
3+ using System . Linq ;
4+
5+ namespace ManagedCode . Communication ;
6+
7+ public abstract class BaseResult < TErrorCode > where TErrorCode : Enum
8+ {
9+ protected BaseResult ( bool isSuccess )
10+ {
11+ IsSuccess = isSuccess ;
12+ }
13+
14+ protected BaseResult ( Error < TErrorCode > error )
15+ {
16+ IsSuccess = false ;
17+ Errors = new List < Error < TErrorCode > > { error } ;
18+ }
19+
20+ protected BaseResult ( List < Error < TErrorCode > > errors )
21+ {
22+ IsSuccess = false ;
23+ Errors = errors ;
24+ }
25+
26+ protected BaseResult ( bool isSuccess , List < Error < TErrorCode > > errors )
27+ {
28+ IsSuccess = isSuccess ;
29+ Errors = errors ;
30+ }
31+
32+ public bool IsSuccess { get ; }
33+ public bool IsFail => ! IsSuccess ;
34+ public Error < TErrorCode > ? Error => Errors ? . FirstOrDefault ( ) ;
35+ public List < Error < TErrorCode > > ? Errors { get ; }
36+ }
Original file line number Diff line number Diff line change 1616 </PropertyGroup >
1717
1818 <ItemGroup >
19- <PackageReference Include =" Microsoft.Extensions.Logging.Abstractions" Version =" 6.0.1" />
19+ <PackageReference Include =" Microsoft.Extensions.Logging.Abstractions" Version =" 6.0.1" />
2020 </ItemGroup >
2121
2222</Project >
You can’t perform that action at this time.
0 commit comments