49 lines
1.4 KiB
C#
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) {
|
|
}
|
|
}
|
|
}
|