コード例 #1
0
        /// <summary>
        /// Initializes the <see cref="ResettableLazy{T}"/> class.
        /// </summary>
        static ResettableLazy()
        {
            ConstructorInfo ctor = typeof(T).GetConstructor(Array <Type> .Empty);

            if (ctor != null)
            {
                _ctorFunc = ctor.Func <T>();
                return;
            }

            if (typeof(T).IsValueType)
            {
                _ctorFunc = Expression.Lambda <Func <T> >(Expression.Constant(default(T))).Compile();
            }
        }