public StrategyI(StrategySettings settings, NeuralStockSettings appSettings) { Settings = settings ?? new StrategySettings(); lock (Locker) { StatisticsService = ApplicationHelper.CurrentCompositionContainer.GetExportedValue <IStatisticsService>(); DataProcessorService = ApplicationHelper.CurrentCompositionContainer.GetExportedValue <IDataProcessorService>(); DownloaderService = ApplicationHelper.CurrentCompositionContainer.GetExportedValue <IDownloaderService>(); } }
public Task <bool> SaveSettings(NeuralStockSettings settings) { return(Task.Run( () => { try { var settingsDTO = settings.GetDTO(); var settingsTable = _db.GetCollection <NeuralStockSettingsDTO>(DbCollectionStringSettings); settingsTable.Upsert(settingsDTO); return true; } catch (Exception ex) { _loggingService.Warn($"{nameof(SaveSettings)}: {ex}"); return false; } })); }
public Task <NeuralStockSettings> GetSettings() { return(Task.Run( () => { if (_db.CollectionExists(DbCollectionStringSettings)) { try { var settingsDto = _db.GetCollection <NeuralStockSettingsDTO>(DbCollectionStringSettings).FindAll(); return NeuralStockSettings.FromDTO(settingsDto.FirstOrDefault()); } catch (Exception ex) { _loggingService.Warn($"{nameof(GetSettings)}: {ex}"); } } return null; })); }
private async Task LoadSettings() { this._settings = await this.PersistenceService.GetSettings().ConfigureAwait(false) ?? new NeuralStockSettings(); }
private async void LoadSettings() { this.Settings = await this.PersistenceService.GetSettings() ?? NeuralStockSettings.GetDefault(); }