示例#1
0
        void LoadXml(string filename)
        {
            idmax = -1;
            dict_url.Clear();
            dict_id.Clear();

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load(filename);
            foreach (System.Xml.XmlElement elem in doc.GetElementsByTagName("favicon"))
            {
                FaviconData icon = new FaviconData();
                if (!int.TryParse(elem.GetAttribute("id"), out icon.id))
                {
                    continue;
                }
                icon.url  = elem.GetAttribute("url");
                icon.data = elem.GetAttribute("data");

                if (idmax < icon.id)
                {
                    idmax = icon.id;
                }
                dict_url[icon.url] = icon;
                dict_id[icon.id]   = icon;
            }
        }
示例#2
0
        //-------------------------------------------------------------------------
        public void Add(string url, string data)
        {
            if (dict_url.ContainsKey(url))
            {
                if (data != "")
                {
                    dict_url[url].data = data;                       // 更新
                }
            }
            else
            {
                // 新規追加
                FaviconData icon = new FaviconData();
                icon.id   = ++idmax;
                icon.url  = url;
                icon.data = data;

                // 追加
                dict_url[icon.url] = icon;
                dict_id[icon.id]   = icon;
            }
        }