示例#1
0
        } //  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);
            }
        }
示例#2
0
		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);
			}
		}
示例#3
0
        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);
            }
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }
示例#6
0
 public bool TryGetEmoji(string name, out Emoji emoji)
 {
     return(_emojis.TryGetValue(name, out emoji));
 }
示例#7
0
 private void DownloadEmoji(Emoji emoji)
 {
     Task.Run(async() => await _downloader.DownloadEmojiAsync(emoji));
 }
示例#8
0
		public bool TryGetEmoji(string name, out Emoji emoji)
		{
			return _emojis.TryGetValue(name, out emoji);
		}
示例#9
0
		private void DownloadEmoji(Emoji emoji)
		{
			Task.Run(async () => await _downloader.DownloadEmojiAsync(emoji));
		}