1234567891011121314151617181920212223242526272829 |
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- namespace OpenSEMI.Core.Container
- {
- internal class ParameterCache
- {
- private static ConcurrentDictionary<ConstructorInfo, List<ParameterInfo>> _parameterCache = new ConcurrentDictionary<ConstructorInfo, List<ParameterInfo>>();
- public static List<ParameterInfo> GetParameters(ConstructorInfo constructor)
- {
- if (!_parameterCache.TryGetValue(constructor, out List<ParameterInfo> value))
- {
- List<ParameterInfo> list2 = _parameterCache[constructor] = DiscoverParameters(constructor);
- value = list2;
- return value;
- }
- return value;
- }
- private static List<ParameterInfo> DiscoverParameters(ConstructorInfo constructor)
- {
- return constructor.GetParameters().ToList();
- }
- }
- }
|