using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Reflection; namespace OpenSEMI.Core.Container { internal class ParameterCache { private static ConcurrentDictionary> _parameterCache = new ConcurrentDictionary>(); public static List GetParameters(ConstructorInfo constructor) { List parameterInfo; if (!_parameterCache.TryGetValue(constructor, out parameterInfo)) { // Not in cache, discover and add to cache. parameterInfo = _parameterCache[constructor] = DiscoverParameters(constructor); } return parameterInfo; } private static List DiscoverParameters(ConstructorInfo constructor) { return constructor.GetParameters().ToList(); } } }