Skip to content

Commit 32ef3e6

Browse files
committed
refactoring
1 parent 35b7760 commit 32ef3e6

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

ManagedCode.Communication/Base/BaseResult.T.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,14 @@ protected BaseResult(bool isSuccess, List<Error<TErrorCode>> errors, T value) :
5454
{
5555
return Value ?? defaultValue;
5656
}
57+
58+
public static bool operator== (BaseResult<T, TErrorCode> obj1, bool obj2)
59+
{
60+
return obj1.IsSuccess == obj2;
61+
}
62+
63+
public static bool operator!= (BaseResult<T, TErrorCode> obj1, bool obj2)
64+
{
65+
return obj1.IsSuccess != obj2;
66+
}
5767
}

ManagedCode.Communication/Base/BaseResult.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,14 @@ protected BaseResult(bool isSuccess, List<Error<TErrorCode>> errors)
3333
public bool IsFail => !IsSuccess;
3434
public Error<TErrorCode>? Error => Errors?.FirstOrDefault();
3535
public List<Error<TErrorCode>>? Errors { get; }
36+
37+
public static bool operator== (BaseResult<TErrorCode> obj1, bool obj2)
38+
{
39+
return obj1.IsSuccess == obj2;
40+
}
41+
42+
public static bool operator!= (BaseResult<TErrorCode> obj1, bool obj2)
43+
{
44+
return obj1.IsSuccess != obj2;
45+
}
3646
}

ManagedCode.Communication/Extensions/ResultExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace ManagedCode.Communication.Extensions;
55

6+
//TODO: move in into class, to avoid changing type when AsTask is called
67
public static class ResultExtensions
78
{
89
public static Task<BaseResult<T, TErrorCode>> AsTask<T, TErrorCode>(this BaseResult<T, TErrorCode> result) where TErrorCode : Enum

0 commit comments

Comments
 (0)