예제 #1
0
        public void Persist()
        {
            _logger.Information($"Reflection settings folder: {_extraDataPathProvider.Path}");
            _logger.Information($"Reflection settings subpath: {SettingsSubPath}");
            var doc = new JObject();

            ObjVM.Persist(doc, _logger.Information);
            if (!_fileSystem.Directory.Exists(_extraDataPathProvider.Path))
            {
                _logger.Information($"Creating reflection settings directory");
                _fileSystem.Directory.CreateDirectory(Path.GetDirectoryName(SettingsPath) !);
            }
            _logger.Information($"Writing reflection settings to: {SettingsPath}");
            _fileSystem.File.WriteAllText(SettingsPath, doc.ToString());
        }
예제 #2
0
        public async Task Import(
            CancellationToken cancel)
        {
            if (!_fileSystem.File.Exists(SettingsPath))
            {
                return;
            }
            var txt = await _fileSystem.File.ReadAllTextAsync(SettingsPath, cancel).ConfigureAwait(false);

            var json = JsonDocument.Parse(txt, new JsonDocumentOptions()
            {
                AllowTrailingCommas = true
            });

            ObjVM.Import(json.RootElement, _logger.Information);
        }