@@ -23,8 +23,8 @@ namespace EddiCommanderMonitor
2323 [ UsedImplicitly ]
2424 public class CommanderMonitor : IEddiMonitor , INotifyPropertyChanged
2525 {
26- private static readonly object commanderLock = new object ( ) ;
27- private readonly CancellationTokenSource cts = new CancellationTokenSource ( ) ;
26+ private static readonly object commanderLock = new ( ) ;
27+ private readonly CancellationTokenSource cts = new ( ) ;
2828
2929 #region Monitored Variables
3030
@@ -84,12 +84,12 @@ public class GenderOption
8484 }
8585
8686 [ UsedImplicitly ]
87- public static ObservableCollection < GenderOption > GenderOptions { get ; set ; } = new ObservableCollection < GenderOption >
88- {
89- new GenderOption { Gender = Gender . Male , DisplayName = Properties . Resources . tab_commander_gender_m } ,
90- new GenderOption { Gender = Gender . Female , DisplayName = Properties . Resources . tab_commander_gender_f } ,
91- new GenderOption { Gender = Gender . Neither , DisplayName = Properties . Resources . tab_commander_gender_n }
92- } ;
87+ public static ObservableCollection < GenderOption > GenderOptions { get ; set ; } =
88+ [
89+ new ( ) { Gender = Gender . Male , DisplayName = Properties . Resources . tab_commander_gender_m } ,
90+ new ( ) { Gender = Gender . Female , DisplayName = Properties . Resources . tab_commander_gender_f } ,
91+ new ( ) { Gender = Gender . Neither , DisplayName = Properties . Resources . tab_commander_gender_n }
92+ ] ;
9393
9494 [ CanBeNull ]
9595 public StarSystem HomeStarSystem // May be null when the commander hasn't set a home star system
@@ -155,7 +155,7 @@ private async Task FetchHomeSystemAsync ( string systemName )
155155
156156 private static bool _isFetchingHomeSystem ;
157157
158- public ObservableCollection < Station > HomeStationOptions { get ; } = new ObservableCollection < Station > ( ) ;
158+ public ObservableCollection < Station > HomeStationOptions { get ; } = [ ] ;
159159
160160 private void UpdateHomeStationOptions ( )
161161 {
@@ -245,7 +245,8 @@ private async Task FetchSquadronSystemAsync(string systemName)
245245 // Ensure collection modifications happen on the UI thread
246246 if ( System . Windows . Application . Current ? . Dispatcher ? . CheckAccess ( ) == false )
247247 {
248- await System . Windows . Application . Current . Dispatcher . InvokeAsync ( ( ) => FetchSquadronSystemAsync ( systemName ) ) ;
248+ await System . Windows . Application . Current . Dispatcher . InvokeAsync ( async ( ) =>
249+ await FetchSquadronSystemAsync ( systemName ) ) ;
249250 return ;
250251 }
251252
@@ -273,7 +274,7 @@ private async Task FetchSquadronSystemAsync(string systemName)
273274
274275 private static bool _isFetchingSquadronSystem ;
275276
276- public ObservableCollection < Faction > SquadronFactions { get ; } = new ObservableCollection < Faction > ( ) ;
277+ public ObservableCollection < Faction > SquadronFactions { get ; } = [ ] ;
277278
278279 private void UpdateSquadronFactions ( )
279280 {
@@ -311,8 +312,8 @@ public Faction SelectedSquadronFaction
311312 }
312313 private Faction _selectedSquadronFaction ;
313314
314- public ObservableCollection < Power > SquadronPowers => new ObservableCollection < Power > ( Power . AllOfThem
315- . Except ( new [ ] { Power . None } )
315+ public static ObservableCollection < Power > SquadronPowers => new ( Power . AllOfThem
316+ . Except ( [ Power . None ] )
316317 . OrderBy ( p => p . localizedName )
317318 . Prepend ( Power . None )
318319 . ToHashSet ( ) ) ;
@@ -487,7 +488,7 @@ private void handleCarrierJumpedEvent ( CarrierJumpedEvent @event )
487488 {
488489 SetCommanderTitle ( @event . controllingsystemfaction . Allegiance ) ;
489490 }
490- if ( ( @event . docked || @event . onFoot ) && @event . factions . Any ( ) && EDDI . Instance . CurrentStarSystem != null )
491+ if ( ( @event . docked || @event . onFoot ) && @event . factions . Count > 0 && EDDI . Instance . CurrentStarSystem != null )
491492 {
492493 if ( @event . timestamp >= updatedAt &&
493494 TryUpdateSquadronHomeSystem ( @event . systemAddress , @event . factions ) )
@@ -603,7 +604,7 @@ private void handleJumpedEvent ( JumpedEvent @event )
603604 {
604605 SetCommanderTitle ( @event . controllingfaction ? . Allegiance ) ;
605606 }
606- if ( @event . factions . Any ( ) && EDDI . Instance . CurrentStarSystem != null )
607+ if ( @event . factions . Count > 0 && EDDI . Instance . CurrentStarSystem != null )
607608 {
608609 if ( @event . timestamp >= updatedAt &&
609610 TryUpdateSquadronHomeSystem ( @event . systemAddress , @event . factions ) )
@@ -619,7 +620,7 @@ private void handleLocationEvent ( LocationEvent @event )
619620 {
620621 SetCommanderTitle ( @event . controllingsystemfaction . Allegiance ) ;
621622 }
622- if ( @event . factions . Any ( ) && EDDI . Instance . CurrentStarSystem != null )
623+ if ( @event . factions . Count > 0 && EDDI . Instance . CurrentStarSystem != null )
623624 {
624625 if ( @event . timestamp >= updatedAt &&
625626 TryUpdateSquadronHomeSystem ( @event . systemAddress , @event . factions ) )
@@ -786,7 +787,7 @@ private void handleSquadronStatusEvent ( SquadronStatusEvent @event )
786787
787788 private bool TryUpdateSquadronHomeSystem ( ulong currentSystemAddress , List < Faction > systemFactions )
788789 {
789- bool update = false ;
790+ var update = false ;
790791
791792 // Check if current system is inhabited by or HQ for squadron faction
792793 var squadronFaction = systemFactions . FirstOrDefault ( f =>
@@ -875,12 +876,14 @@ private void SetCommanderTitle ( Superpower controllingFactionAllegiance )
875876 if ( controllingFactionAllegiance != null )
876877 {
877878 if ( controllingFactionAllegiance . invariantName == Superpower . Federation . invariantName &&
878- Cmdr . federationrating != null && Cmdr . federationrating . rank > minFederationRankForTitle )
879+ Cmdr . federationrating is { } rating &&
880+ rating . rank > minFederationRankForTitle )
879881 {
880882 Cmdr . title = Cmdr . federationrating . localizedName ;
881883 }
882884 else if ( controllingFactionAllegiance . invariantName == Superpower . Empire . invariantName &&
883- Cmdr . empirerating != null && Cmdr . empirerating . rank > minEmpireRankForTitle )
885+ Cmdr . empirerating is { } empireRating &&
886+ empireRating . rank > minEmpireRankForTitle )
884887 {
885888 Cmdr . title = Cmdr . empirerating . maleRank . localizedName ;
886889 }
@@ -891,7 +894,7 @@ private void SetCommanderTitle ( Superpower controllingFactionAllegiance )
891894 private Commander ReadCommander ( CommanderConfiguration configuration = null )
892895 {
893896 // Obtain current commander from our configuration
894- configuration = configuration ?? ConfigService . Instance . commanderConfiguration ;
897+ configuration ??= ConfigService . Instance . commanderConfiguration ;
895898 var commander = new Commander
896899 {
897900 name = configuration . commanderName ,
0 commit comments