@@ -32,41 +32,93 @@ public int CompareTo(object obj)
3232
3333 public static bool operator < ( BaseMoney moneyLeft , BaseMoney moneyRight )
3434 {
35+ if ( ReferenceEquals ( moneyLeft , moneyRight ) )
36+ {
37+ return false ;
38+ }
39+ if ( ReferenceEquals ( moneyLeft , null ) || ReferenceEquals ( moneyRight , null ) )
40+ {
41+ return false ;
42+ }
3543 return moneyLeft . CompareTo ( moneyRight ) < 0 ;
3644 }
3745
3846 public static bool operator > ( BaseMoney moneyLeft , BaseMoney moneyRight )
3947 {
48+ if ( ReferenceEquals ( moneyLeft , moneyRight ) )
49+ {
50+ return false ;
51+ }
52+ if ( ReferenceEquals ( moneyLeft , null ) || ReferenceEquals ( moneyRight , null ) )
53+ {
54+ return false ;
55+ }
4056 return moneyLeft . CompareTo ( moneyRight ) > 0 ;
4157 }
4258
4359 public static bool operator <= ( BaseMoney moneyLeft , BaseMoney moneyRight )
4460 {
61+ if ( ReferenceEquals ( moneyLeft , moneyRight ) )
62+ {
63+ return false ;
64+ }
65+ if ( ReferenceEquals ( moneyLeft , null ) || ReferenceEquals ( moneyRight , null ) )
66+ {
67+ return false ;
68+ }
4569 return moneyLeft . CompareTo ( moneyRight ) <= 0 ;
4670 }
4771
4872 public static bool operator >= ( BaseMoney moneyLeft , BaseMoney moneyRight )
4973 {
74+ if ( ReferenceEquals ( moneyLeft , moneyRight ) )
75+ {
76+ return false ;
77+ }
78+ if ( ReferenceEquals ( moneyLeft , null ) || ReferenceEquals ( moneyRight , null ) )
79+ {
80+ return false ;
81+ }
5082 return moneyLeft . CompareTo ( moneyRight ) >= 0 ;
5183 }
5284
5385 public static bool operator == ( BaseMoney moneyLeft , BaseMoney moneyRight )
5486 {
87+ if ( ReferenceEquals ( moneyLeft , moneyRight ) )
88+ {
89+ return true ;
90+ }
91+ if ( ReferenceEquals ( moneyLeft , null ) || ReferenceEquals ( moneyRight , null ) )
92+ {
93+ return false ;
94+ }
5595 return moneyLeft . CompareTo ( moneyRight ) == 0 ;
5696 }
5797
5898 public static bool operator != ( BaseMoney moneyLeft , BaseMoney moneyRight )
5999 {
100+ if ( ReferenceEquals ( moneyLeft , moneyRight ) )
101+ {
102+ return false ;
103+ }
104+ if ( ReferenceEquals ( moneyLeft , null ) || ReferenceEquals ( moneyRight , null ) )
105+ {
106+ return true ;
107+ }
60108 return moneyLeft . CompareTo ( moneyRight ) != 0 ;
61109 }
62110
63111 public override bool Equals ( object obj )
64112 {
65- if ( ! ( obj is BaseMoney money ) )
113+ if ( ReferenceEquals ( this , obj ) )
66114 {
67- throw new ArgumentException ( ) ;
115+ return true ;
68116 }
69- if ( this . CurrencyCode != money . CurrencyCode )
117+ if ( ReferenceEquals ( obj , null ) || ReferenceEquals ( this , null ) )
118+ {
119+ return false ;
120+ }
121+ if ( ! ( obj is BaseMoney money ) )
70122 {
71123 throw new ArgumentException ( ) ;
72124 }
0 commit comments