async Task TryLoadVersionInfo() { try { VersionInfo = await GetToolsInfo(VersionInfoFile).ConfigureAwait(false); } catch (KeyNotFoundException) { VersionInfo = new VersionInfoDto(); } }
public VersionRegistry(Uri uri, IApiLocalObjectCacheManager cacheManager, ISystemInfo systemInfo) { _cacheManager = cacheManager; _systemInfo = systemInfo; _versionInfoUrl = Tools.Transfer.JoinUri(uri, VersionInfoFile); LocalVersionInfo = new VersionInfoDto(); VersionInfo = new VersionInfoDto(); }
async Task TryDownloadVersionInfo() { VersionInfoDto versionInfo; try { var dl = await _cacheManager.Download(_versionInfoUrl, TimeSpan.FromSeconds(30)); versionInfo = Encoding.UTF8.GetString(dl).FromJson<VersionInfoDto>(); } catch (Exception) { versionInfo = new VersionInfoDto(); } await Save(VersionInfoFile, versionInfo).ConfigureAwait(false); VersionInfo = versionInfo; }
async Task Save(string file, VersionInfoDto obj) { await _cacheManager.SetObject(file, obj.ToJson()); }