Skip to content

Commit ac1aa54

Browse files
committed
Resharper cleanup
1 parent 4f59f73 commit ac1aa54

20 files changed

+59
-120
lines changed

src/Bible.Alarm/App.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using Bible.Alarm.Common.Messenger;
55
using Bible.Alarm.Services.Media;
66
using Bible.Alarm.ViewModels;
7-
using Bible.Alarm.ViewModels.Shared;
87
using Bible.Alarm.Views;
98
using Bible.Alarm.Views.General;
109
using CommunityToolkit.Mvvm.Messaging;

src/Bible.Alarm/Services/Media/ScheduleDisplayService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using Bible.Alarm.Models.Schedule;
44
using Bible.Alarm.Shared.Database;
55
using Microsoft.EntityFrameworkCore;
6-
using Microsoft.Extensions.DependencyInjection;
76
using Serilog;
87

98
namespace Bible.Alarm.Services.Media;

src/Bible.Alarm/Services/UI/NavigationService.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
using Bible.Alarm.Common.Interfaces.UI;
2-
using Bible.Alarm.ViewModels;
3-
using Bible.Alarm.ViewModels.Bible;
4-
using Bible.Alarm.ViewModels.Music;
52
using Bible.Alarm.ViewModels.Shared;
63
using Bible.Alarm.Views;
74
using Bible.Alarm.Views.Bible;
85
using Bible.Alarm.Views.Music;
96
using Bible.Alarm.Views.General;
107
using Bible.Alarm.Views.Schedule;
118
using Bible.Alarm.Views.Shared;
12-
using Microsoft.Extensions.DependencyInjection;
139

1410
namespace Bible.Alarm.Services.UI;
1511

src/Bible.Alarm/ViewModels/Bible/BibleSelectionViewModel.cs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
using Bible.Alarm.Stores;
88
using Bible.Alarm.Stores.Actions.Bible;
99
using Bible.Alarm.ViewModels.Shared;
10-
using Bible.Alarm.Views.Bible;
11-
using Bible.Alarm.Views.Shared;
1210
using CommunityToolkit.Mvvm.ComponentModel;
1311
using CommunityToolkit.Mvvm.Input;
1412
using Fluxor;
@@ -19,9 +17,6 @@ namespace Bible.Alarm.ViewModels.Bible;
1917
public class BibleSelectionViewModel : ObservableObject, IListViewModel
2018
{
2119
private readonly MediaService _mediaService;
22-
private readonly IServiceScopeFactory _scopeFactory;
23-
private readonly INavigationService _navigationService;
24-
private readonly IDispatcher _dispatcher;
2520
private readonly IState<ApplicationState> _state;
2621

2722
private BibleReadingSchedule _current;
@@ -36,10 +31,9 @@ public class BibleSelectionViewModel : ObservableObject, IListViewModel
3631
public BibleSelectionViewModel(MediaService mediaService, IServiceScopeFactory scopeFactory, INavigationService navigationService)
3732
{
3833
_mediaService = mediaService;
39-
_scopeFactory = scopeFactory;
40-
_navigationService = navigationService;
34+
var navigationService1 = navigationService;
4135
_state = MauiAppHolder.Services.GetRequiredService<IState<ApplicationState>>();
42-
_dispatcher = MauiAppHolder.Services.GetRequiredService<IDispatcher>();
36+
var dispatcher = MauiAppHolder.Services.GetRequiredService<IDispatcher>();
4337

4438
_state.StateChanged += OnBibleReadingInitialized;
4539

@@ -51,8 +45,8 @@ public BibleSelectionViewModel(MediaService mediaService, IServiceScopeFactory s
5145
BookSelectionCommand = new AsyncRelayCommand<PublicationListViewItemModel>(async x =>
5246
{
5347
IsBusy = true;
54-
await _navigationService.NavigateToBookSelectionAsync();
55-
_dispatcher.Dispatch(new BookSelectionAction(new BibleReadingSchedule
48+
await navigationService1.NavigateToBookSelectionAsync();
49+
dispatcher.Dispatch(new BookSelectionAction(new BibleReadingSchedule
5650
{
5751
PublicationCode = x.Code,
5852
LanguageCode = CurrentLanguage.Code
@@ -63,21 +57,21 @@ public BibleSelectionViewModel(MediaService mediaService, IServiceScopeFactory s
6357
OpenModalCommand = new AsyncRelayCommand(async () =>
6458
{
6559
IsBusy = true;
66-
await _navigationService.OpenLanguageModalAsync(this);
60+
await navigationService1.OpenLanguageModalAsync(this);
6761
IsBusy = false;
6862
});
6963

7064
BackCommand = new AsyncRelayCommand(async () =>
7165
{
7266
IsBusy = true;
73-
await _navigationService.PopAsync();
67+
await navigationService1.PopAsync();
7468
IsBusy = false;
7569
});
7670

7771
CloseModalCommand = new AsyncRelayCommand(async () =>
7872
{
7973
IsBusy = true;
80-
await _navigationService.CloseModalAsync();
74+
await navigationService1.CloseModalAsync();
8175
IsBusy = false;
8276
});
8377

@@ -89,7 +83,7 @@ public BibleSelectionViewModel(MediaService mediaService, IServiceScopeFactory s
8983
CurrentLanguage = x;
9084
CurrentLanguage.IsSelected = true;
9185

92-
await _navigationService.CloseModalAsync();
86+
await navigationService1.CloseModalAsync();
9387
await PopulateTranslations(x.Code);
9488

9589
IsBusy = false;

src/Bible.Alarm/ViewModels/Bible/BookSelectionViewModel.cs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using Bible.Alarm.Shared.Models.Media.Bible;
88
using Bible.Alarm.Stores;
99
using Bible.Alarm.Stores.Actions.Bible;
10-
using Bible.Alarm.Views.Bible;
1110
using CommunityToolkit.Mvvm.ComponentModel;
1211
using CommunityToolkit.Mvvm.Input;
1312
using Fluxor;
@@ -21,36 +20,32 @@ public class BookSelectionViewModel : ObservableObject, IDisposable
2120
private BibleReadingSchedule _tentative;
2221

2322
private readonly MediaService _mediaService;
24-
private readonly IServiceScopeFactory _scopeFactory;
25-
private readonly INavigationService _navigationService;
26-
private readonly IDispatcher _dispatcher;
2723
private readonly IState<ApplicationState> _state;
2824
private EventHandler _onBibleReadingChanged;
2925
private EventHandler _onBibleReadingInitialized;
3026

3127
public ICommand BackCommand { get; set; }
3228
public ICommand ChapterSelectionCommand { get; set; }
3329

34-
public BookSelectionViewModel(MediaService mediaService, IServiceScopeFactory scopeFactory, INavigationService navigationService)
30+
public BookSelectionViewModel(MediaService mediaService, INavigationService navigationService)
3531
{
3632
_mediaService = mediaService;
37-
_scopeFactory = scopeFactory;
38-
_navigationService = navigationService;
33+
var navigationService1 = navigationService;
3934
_state = MauiAppHolder.Services.GetRequiredService<IState<ApplicationState>>();
40-
_dispatcher = MauiAppHolder.Services.GetRequiredService<IDispatcher>();
35+
var dispatcher = MauiAppHolder.Services.GetRequiredService<IDispatcher>();
4136

4237
BackCommand = new AsyncRelayCommand(async () =>
4338
{
4439
IsBusy = true;
45-
await _navigationService.PopAsync();
40+
await navigationService1.PopAsync();
4641
IsBusy = false;
4742
});
4843

4944
ChapterSelectionCommand = new AsyncRelayCommand<BibleBookListViewItemModel>(async x =>
5045
{
5146
IsBusy = true;
52-
await _navigationService.NavigateToChapterSelectionAsync();
53-
_dispatcher.Dispatch(new ChapterSelectionAction(new BibleReadingSchedule
47+
await navigationService1.NavigateToChapterSelectionAsync();
48+
dispatcher.Dispatch(new ChapterSelectionAction(new BibleReadingSchedule
5449
{
5550
LanguageCode = _tentative.LanguageCode,
5651
PublicationCode = _tentative.PublicationCode,
@@ -189,7 +184,6 @@ public bool IsSelected
189184

190185
public int CompareTo(object obj)
191186
{
192-
if (obj is not BibleBookListViewItemModel other) return 1;
193-
return Number.CompareTo(other.Number);
187+
return obj is not BibleBookListViewItemModel other ? 1 : Number.CompareTo(other.Number);
194188
}
195189
}

src/Bible.Alarm/ViewModels/Bible/ChapterSelectionViewModel.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,11 @@ public class ChapterSelectionViewModel : ObservableObject, IDisposable
2424
private readonly MediaService _mediaService;
2525
private readonly IToastService _toastService;
2626
private readonly IPreviewPlayService _playService;
27-
private readonly INavigationService _navigationService;
2827
private BibleReadingSchedule _current;
2928
private BibleReadingSchedule _tentative;
3029
private readonly IMediaCacheService _cacheService;
3130
private readonly IDownloadService _downloadService;
3231
private readonly IState<ApplicationState> _state;
33-
private readonly IDispatcher _dispatcher;
3432

3533
private readonly Dictionary<BibleChapterListViewItemModel, PropertyChangedEventHandler> _propertyChangedHandlers = [];
3634

@@ -47,18 +45,18 @@ public ChapterSelectionViewModel(
4745
_mediaService = mediaService;
4846
_toastService = toastService;
4947
_playService = playService;
50-
_navigationService = navigationService;
48+
var navigationService1 = navigationService;
5149

5250
_downloadService = downloadService;
5351
_cacheService = cacheService;
5452

5553
_state = MauiAppHolder.Services.GetRequiredService<IState<ApplicationState>>();
56-
_dispatcher = MauiAppHolder.Services.GetRequiredService<IDispatcher>();
54+
var dispatcher = MauiAppHolder.Services.GetRequiredService<IDispatcher>();
5755

5856
BackCommand = new AsyncRelayCommand(async () =>
5957
{
6058
IsBusy = true;
61-
await _navigationService.PopAsync();
59+
await navigationService1.PopAsync();
6260
IsBusy = false;
6361
});
6462

@@ -73,7 +71,7 @@ public ChapterSelectionViewModel(
7371

7472
_tentative.ChapterNumber = x.Number;
7573

76-
_dispatcher.Dispatch(new ChapterSelectedAction(new BibleReadingSchedule
74+
dispatcher.Dispatch(new ChapterSelectedAction(new BibleReadingSchedule
7775
{
7876
LanguageCode = _tentative.LanguageCode,
7977
PublicationCode = _tentative.PublicationCode,

src/Bible.Alarm/ViewModels/HomeViewModel.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using Bible.Alarm.Stores;
99
using Bible.Alarm.Stores.Actions;
1010
using Bible.Alarm.Stores.Actions.Schedule;
11-
using Bible.Alarm.Views.Schedule;
1211
using CommunityToolkit.Mvvm.ComponentModel;
1312
using CommunityToolkit.Mvvm.Input;
1413
using Fluxor;
@@ -25,7 +24,6 @@ public class HomeViewModel : ObservableObject, IDisposable
2524

2625
private readonly IDatabaseSeedService _databaseSeedService;
2726
private readonly IScheduleMigrationService _scheduleMigrationService;
28-
private readonly INavigationService _navigationService;
2927

3028
private readonly Dictionary<int, ScheduleListItem> _scheduleViewModels = [];
3129

@@ -50,18 +48,18 @@ public HomeViewModel(
5048
_dispatcher = MauiAppHolder.Services.GetRequiredService<IDispatcher>();
5149
_databaseSeedService = databaseSeedService;
5250
_scheduleMigrationService = scheduleMigrationService;
53-
_navigationService = navigationService;
51+
var navigationService1 = navigationService;
5452

5553
AddScheduleCommand = new AsyncRelayCommand(async () =>
5654
{
57-
await _navigationService.NavigateToScheduleAsync();
55+
await navigationService1.NavigateToScheduleAsync();
5856
_dispatcher.Dispatch(new ViewScheduleAction(null));
5957
});
6058

6159
ViewScheduleCommand = new AsyncRelayCommand<ScheduleListItem>(async x =>
6260
{
6361
x.Schedule.IsEnabled = x.IsEnabled;
64-
await _navigationService.NavigateToScheduleAsync();
62+
await navigationService1.NavigateToScheduleAsync();
6563
_dispatcher.Dispatch(new ViewScheduleAction(x.Schedule));
6664
});
6765

src/Bible.Alarm/ViewModels/Music/MusicSelectionViewModel.cs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using Bible.Alarm.Shared.Models.Enums;
77
using Bible.Alarm.Stores;
88
using Bible.Alarm.Stores.Actions.Music;
9-
using Bible.Alarm.Views.Music;
109
using CommunityToolkit.Mvvm.ComponentModel;
1110
using CommunityToolkit.Mvvm.Input;
1211
using Fluxor;
@@ -18,17 +17,13 @@ public class MusicSelectionViewModel : ObservableObject
1817
{
1918
private AlarmMusic _current;
2019

21-
private readonly IServiceScopeFactory _scopeFactory;
22-
private readonly INavigationService _navigationService;
23-
private readonly IDispatcher _dispatcher;
2420
private readonly IState<ApplicationState> _state;
2521

2622
public MusicSelectionViewModel(IServiceScopeFactory scopeFactory, INavigationService navigationService)
2723
{
28-
_scopeFactory = scopeFactory;
29-
_navigationService = navigationService;
24+
var navigationService1 = navigationService;
3025
_state = MauiAppHolder.Services.GetRequiredService<IState<ApplicationState>>();
31-
_dispatcher = MauiAppHolder.Services.GetRequiredService<IDispatcher>();
26+
var dispatcher = MauiAppHolder.Services.GetRequiredService<IDispatcher>();
3227

3328
_state.StateChanged += OnStateOnStateChanged;
3429

@@ -38,9 +33,9 @@ public MusicSelectionViewModel(IServiceScopeFactory scopeFactory, INavigationSer
3833

3934
if (x.MusicType == MusicType.Vocals)
4035
{
41-
await _navigationService.NavigateToSongBookSelectionAsync();
36+
await navigationService1.NavigateToSongBookSelectionAsync();
4237

43-
_dispatcher.Dispatch(new SongBookSelectionAction(new AlarmMusic
38+
dispatcher.Dispatch(new SongBookSelectionAction(new AlarmMusic
4439
{
4540
MusicType = MusicType.Vocals,
4641
LanguageCode = _current.LanguageCode
@@ -49,9 +44,9 @@ public MusicSelectionViewModel(IServiceScopeFactory scopeFactory, INavigationSer
4944
}
5045
else
5146
{
52-
await _navigationService.NavigateToTrackSelectionAsync();
47+
await navigationService1.NavigateToTrackSelectionAsync();
5348

54-
_dispatcher.Dispatch(new TrackSelectionAction(new AlarmMusic
49+
dispatcher.Dispatch(new TrackSelectionAction(new AlarmMusic
5550
{
5651
Repeat = _current.Repeat,
5752
MusicType = MusicType.Melodies,
@@ -66,7 +61,7 @@ public MusicSelectionViewModel(IServiceScopeFactory scopeFactory, INavigationSer
6661
BackCommand = new AsyncRelayCommand(async () =>
6762
{
6863
IsBusy = true;
69-
await _navigationService.PopAsync();
64+
await navigationService1.PopAsync();
7065
IsBusy = false;
7166
});
7267
return;

src/Bible.Alarm/ViewModels/Music/SongBookSelectionViewModel.cs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
using Bible.Alarm.Stores;
99
using Bible.Alarm.Stores.Actions.Music;
1010
using Bible.Alarm.ViewModels.Shared;
11-
using Bible.Alarm.Views.Music;
12-
using Bible.Alarm.Views.Shared;
1311
using CommunityToolkit.Mvvm.ComponentModel;
1412
using CommunityToolkit.Mvvm.Input;
1513
using Fluxor;
@@ -20,9 +18,6 @@ namespace Bible.Alarm.ViewModels.Music;
2018
public class SongBookSelectionViewModel : ObservableObject, IListViewModel
2119
{
2220
private readonly MediaService _mediaService;
23-
private readonly IServiceScopeFactory _scopeFactory;
24-
private readonly INavigationService _navigationService;
25-
private readonly IDispatcher _dispatcher;
2621
private readonly IState<ApplicationState> _state;
2722

2823
private AlarmMusic _current;
@@ -31,10 +26,9 @@ public class SongBookSelectionViewModel : ObservableObject, IListViewModel
3126
public SongBookSelectionViewModel(MediaService mediaService, IServiceScopeFactory scopeFactory, INavigationService navigationService)
3227
{
3328
_mediaService = mediaService;
34-
_scopeFactory = scopeFactory;
35-
_navigationService = navigationService;
29+
var navigationService1 = navigationService;
3630
_state = MauiAppHolder.Services.GetRequiredService<IState<ApplicationState>>();
37-
_dispatcher = MauiAppHolder.Services.GetRequiredService<IDispatcher>();
31+
var dispatcher = MauiAppHolder.Services.GetRequiredService<IDispatcher>();
3832

3933
AlarmMusic lastCurrent = null;
4034
AlarmMusic lastTentative = null;
@@ -82,9 +76,9 @@ void OnMusicInitialized(object o, EventArgs eventArgs)
8276
{
8377
IsBusy = true;
8478

85-
await _navigationService.NavigateToTrackSelectionAsync();
79+
await navigationService1.NavigateToTrackSelectionAsync();
8680

87-
_dispatcher.Dispatch(new TrackSelectionAction(new AlarmMusic
81+
dispatcher.Dispatch(new TrackSelectionAction(new AlarmMusic
8882
{
8983
Repeat = _current.Repeat,
9084
MusicType = MusicType.Vocals,
@@ -98,20 +92,20 @@ void OnMusicInitialized(object o, EventArgs eventArgs)
9892
OpenModalCommand = new AsyncRelayCommand(async () =>
9993
{
10094
IsBusy = true;
101-
await _navigationService.OpenLanguageModalAsync(this);
95+
await navigationService1.OpenLanguageModalAsync(this);
10296
IsBusy = false;
10397
});
10498

10599
BackCommand = new AsyncRelayCommand(async () =>
106100
{
107101
IsBusy = true;
108-
await _navigationService.PopAsync();
102+
await navigationService1.PopAsync();
109103
IsBusy = false;
110104
});
111105

112106
CloseModalCommand = new AsyncRelayCommand(async () =>
113107
{
114-
await _navigationService.CloseModalAsync();
108+
await navigationService1.CloseModalAsync();
115109
});
116110

117111
SelectLanguageCommand = new AsyncRelayCommand<LanguageListViewItemModel>(async x =>
@@ -122,7 +116,7 @@ void OnMusicInitialized(object o, EventArgs eventArgs)
122116
CurrentLanguage = x;
123117
CurrentLanguage.IsSelected = true;
124118

125-
await _navigationService.CloseModalAsync();
119+
await navigationService1.CloseModalAsync();
126120
await PopulateSongBooks(x.Code);
127121
IsBusy = false;
128122
});

0 commit comments

Comments
 (0)