示例#1
0
 public void LoadResource(string resource)
 {
     using (var sr = new GZipResourceStream(resource))
     {
         Logger.Info($"Loaded rule resource {resource}");
         LoadStream(sr);
     }
 }
示例#2
0
 public void LoadResource(string resource)
 {
     using (var sr = new GZipResourceStream(resource))
     {
         Log.Debug("Loaded rule resource {0}", resource);
         LoadStream(sr);
     }
 }
示例#3
0
        private static IEnumerable <EmojiCategory> GetAllCategories()
        {
            LUT = new Dictionary <string, EmojiCategory>();

            var match_group    = new Regex(@"^# group: (.*)");
            var match_sequence = new Regex(@"^([0-9A-F ]+[0-9A-F]).*");
            var list           = new List <EmojiCategory>();

            using (var sr = new GZipResourceStream("emoji-test.txt.gz"))
            {
                EmojiCategory last_category = null;
                string        buffer        = sr.ReadToEnd();
                foreach (var line in buffer.Split('\r', '\n'))
                {
                    var m = match_group.Match(line);
                    if (m.Success)
                    {
                        last_category = new EmojiCategory()
                        {
                            Name = m.Groups[1].ToString()
                        };
                        list.Add(last_category);
                    }

                    m = match_sequence.Match(line);
                    if (m.Success)
                    {
                        string value = "";
                        foreach (var codepoint in m.Groups[1].ToString().Split(' '))
                        {
                            value += char.ConvertFromUtf32(Convert.ToInt32(codepoint, 16));
                        }
                        LUT[value] = last_category;

                        // Set icon for this category
                        if (string.IsNullOrEmpty(last_category.Icon))
                        {
                            last_category.Icon = value;
                        }
                    }
                }
            }

            return(list);
        }
示例#4
0
        private static Dictionary <string, string> ReadXorgKeySyms()
        {
            Dictionary <string, string> ret = new Dictionary <string, string>();

            using (var reader = new GZipResourceStream("keysymdef.h.gz"))
            {
                Regex r = new Regex(@"^#define XK_([^ ]*).* U\+([A-Za-z0-9]+)");
                for (string l = reader.ReadLine(); l != null; l = reader.ReadLine())
                {
                    Match m = r.Match(l);
                    if (m.Success)
                    {
                        int codepoint = int.Parse(m.Groups[2].Value, NumberStyles.HexNumber);
                        ret[m.Groups[1].Value] = char.ConvertFromUtf32(codepoint);
                    }
                }
            }
            return(ret);
        }