1- using System . Collections ;
1+ using System ;
2+ using System . Collections ;
23using System . Collections . Generic ;
34using Newtonsoft . Json ;
45using Newtonsoft . Json . Serialization ;
56
67namespace OmniSharp . Extensions . LanguageServer . Protocol . Models
78{
8- public abstract class ContainerBase < T > : IEnumerable < T >
9+ public abstract class ContainerBase < T > : IEnumerable < T > , IEquatable < ContainerBase < T > >
910 {
1011 private readonly IEnumerable < T > _items ;
1112
@@ -14,14 +15,40 @@ public ContainerBase(IEnumerable<T> items)
1415 _items = items ;
1516 }
1617
18+ public override bool Equals ( object obj )
19+ {
20+ return Equals ( obj as ContainerBase < T > ) ;
21+ }
22+
23+ public bool Equals ( ContainerBase < T > other )
24+ {
25+ return other != null &&
26+ EqualityComparer < IEnumerable < T > > . Default . Equals ( _items , other . _items ) ;
27+ }
28+
1729 public IEnumerator < T > GetEnumerator ( )
1830 {
1931 return _items . GetEnumerator ( ) ;
2032 }
2133
34+ public override int GetHashCode ( )
35+ {
36+ return - 566117206 + EqualityComparer < IEnumerable < T > > . Default . GetHashCode ( _items ) ;
37+ }
38+
2239 IEnumerator IEnumerable . GetEnumerator ( )
2340 {
2441 return GetEnumerator ( ) ;
2542 }
43+
44+ public static bool operator == ( ContainerBase < T > base1 , ContainerBase < T > base2 )
45+ {
46+ return EqualityComparer < ContainerBase < T > > . Default . Equals ( base1 , base2 ) ;
47+ }
48+
49+ public static bool operator != ( ContainerBase < T > base1 , ContainerBase < T > base2 )
50+ {
51+ return ! ( base1 == base2 ) ;
52+ }
2653 }
2754}
0 commit comments