コード例 #1
0
		public static List<Emoticon> GetEmoticons(bool refresh = false)
		{
			var emoticons = new List<Emoticon>();

			if (!File.Exists(emoticonsCacheFileName))
			{
				File.Create(emoticonsCacheFileName);
				refresh = true;
			}

			if (refresh)
			{
				using (StreamWriter writer = File.CreateText(emoticonsCacheFileName))
				{
					var chatManager = new ChatManager();

					foreach (Emoticon emoticon in chatManager.GetEmoticons())
					{
						writer.WriteLine(emoticon.Pattern + "," + emoticon.Url);
					}
				}
			}

			using (StreamReader reader = File.OpenText(emoticonsCacheFileName))
			{
				string line;
				while ((line = reader.ReadLine()) != null)
				{
					string[] parts = line.Split(',');

					emoticons.Add(new Emoticon {Pattern = parts[0].Trim(), Url = parts[1].Trim()});
				}
			}

			return emoticons;
		}