Ejemplo n.º 1
0
        public void Read()
        {
            var result = SerializationTools.DeserializeFromXml <List <CacheEntry> >(Filename);

            Cache.Clear();
            foreach (var cacheEntry in result)
            {
                var id = cacheEntry.Entry.GetCacheId();
                if (id == null)
                {
                    continue;
                }

                if (SerializeIcons && cacheEntry.Icon != null)
                {
                    cacheEntry.Entry.IconBitmap = DeserializeIcon(cacheEntry.Icon);
                }

                Cache.Add(id, cacheEntry.Entry);
            }
        }
        public void Read()
        {
            var result = SerializationTools.DeserializeFromXml <List <CacheEntry> >(Filename);

            Cache.Clear();

            // Ignore entries if more than 1 have the same cache id
            foreach (var group in result
                     .GroupBy(x => x.Entry.GetCacheId())
                     .Where(g => g.Key != null && g.CountEquals(1)))
            {
                var cacheEntry = group.Single();

                if (SerializeIcons && cacheEntry.Icon != null)
                {
                    cacheEntry.Entry.IconBitmap = DeserializeIcon(cacheEntry.Icon);
                }

                Cache.Add(group.Key, cacheEntry.Entry);
            }
        }