@@ -11,36 +11,48 @@ public class ActionIds : IUrlParameter, IEquatable<ActionIds>
11
11
{
12
12
private readonly List < string > _actionIds ;
13
13
14
- public ActionIds ( IEnumerable < string > actionIds ) => _actionIds = actionIds ? . ToList ( ) ?? new List < string > ( ) ;
14
+ public ActionIds ( IEnumerable < string > actionIds ) => _actionIds = actionIds ? . ToList ( ) ;
15
15
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
+ }
23
21
24
22
private string DebugDisplay => ( ( IUrlParameter ) this ) . GetString ( null ) ;
25
23
26
24
public bool Equals ( ActionIds other )
27
25
{
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 ;
30
29
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 ) ) ;
32
32
}
33
33
34
- string IUrlParameter . GetString ( IConnectionConfigurationValues settings ) => string . Join ( "," , _actionIds ) ;
34
+ string IUrlParameter . GetString ( IConnectionConfigurationValues settings ) =>
35
+ string . Join ( "," , _actionIds ?? Enumerable . Empty < string > ( ) ) ;
35
36
36
37
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 ) ;
38
39
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 ) ;
40
42
41
43
public override bool Equals ( object obj ) => obj is ActionIds other && Equals ( other ) ;
42
44
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
+ }
44
56
45
57
public static bool operator == ( ActionIds left , ActionIds right ) => Equals ( left , right ) ;
46
58
0 commit comments