Archived
1
0
This repository has been archived on 2021-10-19. You can view files and clone it, but cannot push or open issues or pull requests.
nonabgs/Util/EDDB.cs

49 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using System.Net;
namespace NonaBGS.Util {
public class EDDB {
private static readonly string EDDB_SYSTEMS_ARCHIVE = "https://eddb.io/archive/v6/systems_populated.json";
private string cache_folder = null;
private WebClient client = new WebClient();
private string systems_file = null;
public string SystemsFile => systems_file;
public string Cache {
get => cache_folder;
set => cache_folder = value;
}
public EDDB(string cache_folder) {
this.cache_folder = cache_folder;
Initialise();
}
public void Initialise() {
client.DownloadDataCompleted += Client_DownloadDataCompleted;
}
private void DownloadFile(string url) {
Uri uri = new Uri(url);
string name = Path.GetFileName(uri.AbsolutePath);
systems_file = Path.Combine(this.cache_folder, name);
client.DownloadFileAsync(new Uri(EDDB_SYSTEMS_ARCHIVE), systems_file);
}
public void Download() {
DownloadFile(EDDB_SYSTEMS_ARCHIVE);
}
private void Client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e) {
}
}
}