public static async Task DownloadCarAsync([NotNull] string id, string version = null)
{
try {
var entry = await CmApiProvider.GetContentAsync <AcContentEntry>($"car/{id}");
if (entry != null)
{
if (version != null && entry.UiVersion != version && entry.OriginVersion != version)
{
throw new InformativeException($"Can’t download car “{id}”",
$"Not the required version: indexed is {entry.UiVersion ?? entry.OriginVersion}, while required is {version}.");
}
if (!entry.ImmediateDownload && entry.OriginUrl != null && (Keyboard.Modifiers & ModifierKeys.Control) == 0)
{
WindowsHelper.ViewInBrowser(entry.OriginUrl);
}
else
{
await ContentInstallationManager.Instance.InstallAsync(entry.DownloadUrl, new ContentInstallationParams(false) {
DisplayName = entry.UiName,
Version = entry.UiVersion,
InformationUrl = entry.OriginUrl
});
}
}
else
{
throw new InformativeException($"Can’t download car “{id}”", "Attempt to find a description failed.");
}
} catch (Exception e) {
NonfatalError.Notify($"Can’t download car “{id}”", e);
}
}