private async Task GetAnkiUMediaMappingIfNeeded() { StorageFile mediaAnkiU = await tempDir.TryGetItemAsync("mediaAnkiU") as StorageFile; mediaToDeckIdMap = null; if (mediaAnkiU != null) { mediaToDeckIdMap = new Dictionary <long, Dictionary <string, string> >(); using (FileStream mediaMapFile = new FileStream(mediaAnkiU.Path, FileMode.Open)) { JsonObject json = JsonObject.Parse(HttpSyncer.Stream2String(mediaMapFile)); foreach (var jr in json) { long deckID = long.Parse(jr.Key); Dictionary <string, string> dict = new Dictionary <string, string>(); JsonObject listMediaOfDeck = jr.Value.GetObject(); foreach (var j in listMediaOfDeck) { dict.Add(j.Value.GetString(), j.Key); } mediaToDeckIdMap[deckID] = dict; } } } }
private void GetAnkiMediaMapping(Dictionary <string, string> numToName) { using (FileStream mediaMapFile = new FileStream(tempDir.Path + "\\" + "media", FileMode.Open)) { //WARNING: Java ver needs opposite mapping since their extraction method requires it. JsonObject json = JsonObject.Parse(HttpSyncer.Stream2String(mediaMapFile)); string name; string num; foreach (var jr in json) { num = jr.Key; name = jr.Value.GetString(); numToName.Add(num, name); } } }