@@ -4,59 +4,50 @@ namespace ManagedCode.Communication;
44
55public class Result
66{
7- public Result ( bool isSucceeded , ResultState status , Exception ? error )
7+ public bool IsSuccess { get ; }
8+ public bool IsError => ! IsSuccess ;
9+ public Exception ? Error { get ; }
10+
11+ public Result ( bool isSuccess , Exception ? error )
812 {
9- IsSucceeded = isSucceeded ;
10- Status = status ;
13+ IsSuccess = isSuccess ;
1114 Error = error ;
1215 }
1316
14- public Result ( bool isSucceeded , ResultState status )
17+ public Result ( bool isSuccess )
1518 {
16- IsSucceeded = isSucceeded ;
17- Status = status ;
19+ IsSuccess = isSuccess ;
1820 Error = null ;
1921 }
2022
21- public Result ( Exception ? error , ResultState status )
23+ public Result ( Exception ? error )
2224 {
23- IsSucceeded = false ;
25+ IsSuccess = false ;
2426 Error = error ;
25- Status = status ;
2627 }
2728
28- public bool IsSucceeded { get ; }
29- public bool IsError => ! IsSucceeded ;
30- public Exception ? Error { get ; }
31- public ResultState Status { get ; }
32-
33- public static Result Succeeded ( ResultState status = ResultState . Success )
29+ public static Result Succeed ( )
3430 {
35- return new Result ( true , status ) ;
36- }
37-
38- public static Result < T > Succeeded < T > ( T result , ResultState status = ResultState . Success )
39- {
40- return new Result < T > ( true , result , status ) ;
31+ return new Result ( true ) ;
4132 }
4233
43- public static Result Failed ( ResultState status , Exception ? error = null )
34+ public static Result < T > Succeed < T > ( T result )
4435 {
45- return new Result ( error , status ) ;
36+ return new Result < T > ( true , result ) ;
4637 }
4738
48- public static Result Failed ( Exception ? error , ResultState status = ResultState . Failed )
39+ public static Result Fail ( Exception ? error )
4940 {
50- return new Result ( error , status ) ;
41+ return new Result ( error ) ;
5142 }
52-
53- public static Result < T > Failed < T > ( T result , Exception ? error , ResultState status = ResultState . Success )
43+
44+ public static Result < T > Fail < T > ( T result , Exception ? error )
5445 {
55- return new Result < T > ( true , result , status ) ;
46+ return new Result < T > ( true , result ) ;
5647 }
5748
58- public static Result Failed ( )
49+ public static Result Fail ( )
5950 {
60- return new Result ( null , ResultState . Failed ) ;
51+ return new Result ( null ) ;
6152 }
6253}
0 commit comments