File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 33
44namespace IPConfig . Models ;
55
6+ public class ConnectionTypeComparer : IComparer < ConnectionType >
7+ {
8+ public static readonly ConnectionTypeComparer Instance = new ( ) ;
9+
10+ public int Compare ( ConnectionType x , ConnectionType y )
11+ {
12+ int xOrder = GetConnectionTypeOrder ( x ) ;
13+ int yOrder = GetConnectionTypeOrder ( y ) ;
14+
15+ return xOrder . CompareTo ( yOrder ) ;
16+ }
17+
18+ private static int GetConnectionTypeOrder ( ConnectionType connectionType )
19+ {
20+ return connectionType switch {
21+ ConnectionType . Ethernet => 0 ,
22+ ConnectionType . Wlan => 1 ,
23+ _ => throw new ArgumentOutOfRangeException ( nameof ( connectionType ) , connectionType , null )
24+ } ;
25+ }
26+ }
27+
628public enum ConnectionType
729{
830 Other ,
Original file line number Diff line number Diff line change @@ -378,6 +378,7 @@ private async Task<List<Nic>> GetAllNicsAsync()
378378 ? ( int ) x . OperationalStatus
379379 : Int32 . MaxValue )
380380 . ThenBy ( x => x . SimpleNicType , SimpleNicTypeComparer . Instance )
381+ . ThenBy ( x => x . ConnectionType , ConnectionTypeComparer . Instance )
381382 . ThenBy ( x => x . Name )
382383 . ToList ( ) ) ;
383384
You can’t perform that action at this time.
0 commit comments