Skip to content

Commit cfd1e64

Browse files
committed
Conform to revised J4JHost API re: configuration folders
1 parent 583af2e commit cfd1e64

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

GeoProcessorApp/app/StoreKeyApp.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@ public class StoreKeyApp : IHostedService
4040
private readonly AppConfig _config;
4141
private readonly IHostApplicationLifetime _lifetime;
4242
private readonly IJ4JLogger? _logger;
43-
private readonly J4JHostInfo _hostInfo;
43+
private readonly string _userConfigFolder;
4444
private readonly IJ4JProtection _protection;
4545

4646
public StoreKeyApp(
4747
AppConfig config,
4848
IHostApplicationLifetime lifetime,
4949
IIndex<string, IConfigurationUpdater> configUpdaters,
50-
J4JHostInfo hostInfo,
50+
IJ4JHost host,
5151
IJ4JProtection protection,
5252
IJ4JLogger? logger
5353
)
5454
{
5555
_config = config;
5656
_lifetime = lifetime;
57-
_hostInfo = hostInfo;
57+
_userConfigFolder = host.UserConfigurationFolder;
5858
_protection = protection;
5959

6060
_logger = logger;
@@ -139,7 +139,7 @@ public async Task StartAsync( CancellationToken cancellationToken )
139139
var serialized = JsonSerializer.Serialize( tempConfig, jsonOptions );
140140

141141
await File.WriteAllTextAsync(
142-
Path.Combine( _hostInfo.UserConfigurationFolder, Program.UserConfigFile ),
142+
Path.Combine( _userConfigFolder, Program.UserConfigFile ),
143143
serialized,
144144
cancellationToken );
145145

GeoProcessorWPF/ui/optionswin/vm/OptionsVM.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using System.Text.Json;
2222
using System.Windows.Input;
2323
using J4JSoftware.DependencyInjection;
24+
using J4JSoftware.Logging;
2425
using MahApps.Metro.Controls.Dialogs;
2526
using Microsoft.Extensions.Options;
2627
using Microsoft.Toolkit.Mvvm.ComponentModel;
@@ -32,7 +33,8 @@ public class OptionsVM : ObservableRecipient
3233
{
3334
private readonly IAppConfig _appConfig;
3435
private readonly IUserConfig _userConfig;
35-
private readonly J4JHostInfo _hostInfo;
36+
private readonly string _appConfigFolder;
37+
private readonly string _userConfigFolder;
3638

3739
private CachedAppConfig _cachedAppConfig;
3840
private UserConfig _prevUserConfig;
@@ -42,12 +44,13 @@ public class OptionsVM : ObservableRecipient
4244
public OptionsVM(
4345
IAppConfig appConfig,
4446
IUserConfig userConfig,
45-
J4JHostInfo hostInfo
47+
IJ4JHost host
4648
)
4749
{
4850
_appConfig = appConfig;
4951
_userConfig = userConfig;
50-
_hostInfo = hostInfo;
52+
_appConfigFolder = host.ApplicationConfigurationFolder;
53+
_userConfigFolder = host.UserConfigurationFolder;
5154

5255
SaveCommand = new RelayCommand( SaveCommandHandlerAsync );
5356
ReloadCommand = new RelayCommand( ReloadCommandHandler );
@@ -116,15 +119,15 @@ private async void SaveCommandHandlerAsync()
116119
var userText = JsonSerializer.Serialize( _userConfig, options );
117120

118121
await File.WriteAllTextAsync(
119-
Path.Combine( _hostInfo.UserConfigurationFolder, ViewModelLocator.UserConfigFile ),
122+
Path.Combine( _userConfigFolder, ViewModelLocator.UserConfigFile ),
120123
userText );
121124

122125
_prevUserConfig = _userConfig.Copy();
123126

124127
var appText = JsonSerializer.Serialize( _appConfig, options );
125128

126129
await File.WriteAllTextAsync(
127-
Path.Combine( _hostInfo.ApplicationConfigurationFolder, ViewModelLocator.AppConfigFile ),
130+
Path.Combine( _appConfigFolder, ViewModelLocator.AppConfigFile ),
128131
appText );
129132

130133
_cachedAppConfig = new CachedAppConfig( _appConfig );

0 commit comments

Comments
 (0)