Пример #1
0
        private static DynamicCtorDelegate GetCachedConstructor(Type objectType)
        {
            DynamicCtorDelegate result = null;

            if (!_ctorCache.TryGetValue(objectType, out result))
            {
                lock (_ctorCache)
                {
                    if (!_ctorCache.TryGetValue(objectType, out result))
                    {
                        ConstructorInfo info =
                            objectType.GetConstructor(ctorFlags, null, Type.EmptyTypes, null);
                        result = DynamicMethodHandlerFactory.CreateConstructor(info);
                        _ctorCache.Add(objectType, result);
                    }
                }
            }
            return(result);
        }