File: IconCache.cs

package info (click to toggle)
keepass2-plugin-keepassrpc 2.0.2%2Bdfsg2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,304 kB
  • sloc: cs: 29,001; makefile: 14
file content (30 lines) | stat: -rw-r--r-- 876 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System.Collections.Generic;

namespace KeePassRPC
{
    public abstract class IconCache<T>
    {
        private static readonly object _iconCacheLock = new object();

        private static readonly Dictionary<T, string> _icons = new Dictionary<T, string>();
        public static void AddIcon(T iconId, string base64Representation)
        {
            lock (_iconCacheLock)
            {
                if (!_icons.ContainsKey(iconId))
                    _icons.Add(iconId, base64Representation);
            }
        }

        public static string GetIconEncoding(T iconId)
        {
            lock (_iconCacheLock)
            {
                string base64Representation;
                if (!_icons.TryGetValue(iconId, out base64Representation))
                    return null;
                return base64Representation;
            }
        }
    }
}