} // end of constructor private void add(string id, string item, Emoji emoji) { if (!_dictionary.ContainsKey(id + item)) { _dictionary[id + item] = new List <Emoji> { emoji }; } else { _dictionary[id + item].Add(emoji); } }
private void InitializeFromJson(string json) { foreach (var pair in Json.DeserializeObject<JsonObject>(json)) { var name = pair.Key; var uri = new Uri((string) pair.Value); var emoji = new Emoji(name, uri, EmojiFileName(uri)); if (!emoji.IsRetrieved) DownloadEmoji(emoji); _emojis.Add(name, emoji); } }
private void InitializeFromJson(string json) { foreach (var pair in Json.DeserializeObject <JsonObject>(json)) { var name = pair.Key; var uri = new Uri((string)pair.Value); var emoji = new Emoji(name, uri, EmojiFileName(uri)); if (!emoji.IsRetrieved) { DownloadEmoji(emoji); } _emojis.Add(name, emoji); } }
public async Task DownloadEmojiAsync(Emoji emoji) { var request = new HttpRequestMessage { RequestUri = emoji.Uri, Headers = { { "Connection", "Keep-Alive"}, { "User-Agent", "EmojiVS" }, }, }; var response = await _client.SendAsync(request); var stream = await response.Content.ReadAsStreamAsync(); using (var file = File.OpenWrite(emoji.FileName)) await stream.CopyToAsync(file); }
public async Task DownloadEmojiAsync(Emoji emoji) { var request = new HttpRequestMessage { RequestUri = emoji.Uri, Headers = { { "Connection", "Keep-Alive" }, { "User-Agent", "EmojiVS" }, }, }; var response = await _client.SendAsync(request); var stream = await response.Content.ReadAsStreamAsync(); using (var file = File.OpenWrite(emoji.FileName)) await stream.CopyToAsync(file); }
public bool TryGetEmoji(string name, out Emoji emoji) { return(_emojis.TryGetValue(name, out emoji)); }
private void DownloadEmoji(Emoji emoji) { Task.Run(async() => await _downloader.DownloadEmojiAsync(emoji)); }
public bool TryGetEmoji(string name, out Emoji emoji) { return _emojis.TryGetValue(name, out emoji); }
private void DownloadEmoji(Emoji emoji) { Task.Run(async () => await _downloader.DownloadEmojiAsync(emoji)); }