9using System.Collections.Generic;
10using System.Security.Principal;
18 public static class PrincipalCache
20 private static List<IPrincipal> _cache =
new List<IPrincipal>();
22 private static int _maxCacheSize;
27 public static int MaxCacheSize
31 if (_maxCacheSize == 0)
34 if (
string.IsNullOrEmpty(tmp))
37 _maxCacheSize = Convert.ToInt32(tmp);
43 _maxCacheSize = value;
55 public static IPrincipal GetPrincipal(
string name)
59 foreach (IPrincipal item
in _cache)
60 if (item.Identity.Name == name)
72 public static void AddPrincipal(IPrincipal principal)
76 if (!_cache.Contains(principal))
78 _cache.Add(principal);
79 if (_cache.Count > MaxCacheSize)
88 public static void Clear()