@@ -11,36 +11,48 @@ public class ActionIds : IUrlParameter, IEquatable<ActionIds>
1111 {
1212 private readonly List < string > _actionIds ;
1313
14- public ActionIds ( IEnumerable < string > actionIds ) => _actionIds = actionIds ? . ToList ( ) ?? new List < string > ( ) ;
14+ public ActionIds ( IEnumerable < string > actionIds ) => _actionIds = actionIds ? . ToList ( ) ;
1515
16- public ActionIds ( string actionIds ) => _actionIds = actionIds . IsNullOrEmpty ( )
17- ? new List < string > ( )
18- : actionIds . Split ( new [ ] { "," } , StringSplitOptions . RemoveEmptyEntries )
19- . Select ( s => s . Trim ( ) )
20- . ToList ( ) ;
21-
22- internal IReadOnlyList < string > Ids => _actionIds ;
16+ public ActionIds ( string actionIds )
17+ {
18+ if ( ! actionIds . IsNullOrEmptyCommaSeparatedList ( out var arr ) )
19+ _actionIds = arr . ToList ( ) ;
20+ }
2321
2422 private string DebugDisplay => ( ( IUrlParameter ) this ) . GetString ( null ) ;
2523
2624 public bool Equals ( ActionIds other )
2725 {
28- if ( Ids == null && other . Ids == null ) return true ;
29- if ( Ids == null || other . Ids == null ) return false ;
26+ if ( other == null ) return false ;
27+ if ( _actionIds == null && other . _actionIds == null ) return true ;
28+ if ( _actionIds == null || other . _actionIds == null ) return false ;
3029
31- return Ids . Count == other . Ids . Count && ! Ids . Except ( other . Ids ) . Any ( ) ;
30+ return _actionIds . Count == other . _actionIds . Count &&
31+ _actionIds . OrderBy ( id => id ) . SequenceEqual ( other . _actionIds . OrderBy ( id => id ) ) ;
3232 }
3333
34- string IUrlParameter . GetString ( IConnectionConfigurationValues settings ) => string . Join ( "," , _actionIds ) ;
34+ string IUrlParameter . GetString ( IConnectionConfigurationValues settings ) =>
35+ string . Join ( "," , _actionIds ?? Enumerable . Empty < string > ( ) ) ;
3536
3637 public static implicit operator ActionIds ( string actionIds ) =>
37- actionIds . IsNullOrEmptyCommaSeparatedList ( out var list ) ? null : new ActionIds ( list ) ;
38+ actionIds . IsNullOrEmptyCommaSeparatedList ( out var arr ) ? null : new ActionIds ( arr ) ;
3839
39- public static implicit operator ActionIds ( string [ ] actionIds ) => actionIds . IsEmpty ( ) ? null : new ActionIds ( actionIds ) ;
40+ public static implicit operator ActionIds ( string [ ] actionIds ) =>
41+ actionIds . IsEmpty ( ) ? null : new ActionIds ( actionIds ) ;
4042
4143 public override bool Equals ( object obj ) => obj is ActionIds other && Equals ( other ) ;
4244
43- public override int GetHashCode ( ) => _actionIds . GetHashCode ( ) ;
45+ public override int GetHashCode ( )
46+ {
47+ if ( _actionIds == null ) return 0 ;
48+ unchecked
49+ {
50+ var hc = 0 ;
51+ foreach ( var id in _actionIds . OrderBy ( id => id ) )
52+ hc = hc * 17 + id . GetHashCode ( ) ;
53+ return hc ;
54+ }
55+ }
4456
4557 public static bool operator == ( ActionIds left , ActionIds right ) => Equals ( left , right ) ;
4658
0 commit comments