Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static readonly Lazy<ConcurrentDictionary<Type, Type[]>> InterfacesCachedMappingLazy = new Lazy<ConcurrentDictionary<Type, Type[]>>(() => new ConcurrentDictionary<Type, Type[]>(), LazyThreadSafetyMode.PublicationOnly);
- private static ConcurrentDictionary<Type, Type[]> InterfacesCachedMapping
- {
- get { return InterfacesCachedMappingLazy.Value; }
- }
- public static Type[] GetInterfacesCached(this Type type)
- {
- Type[] interfaces;
- if(!InterfacesCachedMapping.TryGetValue(type, out interfaces))
- {
- interfaces = type.GetInterfaces();
- InterfacesCachedMapping.TryAdd(type, interfaces);
- }
- return interfaces;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement