using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Reflection; namespace OpenSEMI.Core.Container { internal class ConstructorCache { private static ConcurrentDictionary _constructorCache = new ConcurrentDictionary(); public static ConstructorInfo GetConstructor(Type type) { if (!_constructorCache.TryGetValue(type, out ConstructorInfo value)) { ConstructorInfo constructorInfo2 = _constructorCache[type] = DiscoverConstructor(type.GetTypeInfo()); value = constructorInfo2; return value; } return value; } private static ConstructorInfo DiscoverConstructor(TypeInfo typeInfo) { IEnumerable declaredConstructors = typeInfo.DeclaredConstructors; if (declaredConstructors.Any()) { return declaredConstructors.First(); } return null; } } }