Пример #1
0
        private Lazy(Func<T>? valueFactory, LazyThreadSafetyMode mode, bool useDefaultConstructor)
        {
            if (valueFactory == null && !useDefaultConstructor)
                throw new ArgumentNullException(nameof(valueFactory));

            _factory = valueFactory;
            _state = LazyHelper.Create(mode, useDefaultConstructor);
        }
Пример #2
0
        private Lazy(Func <T>?valueFactory, LazyThreadSafetyMode mode, bool useDefaultConstructor)
        {
            if (!useDefaultConstructor)
            {
                ArgumentNullException.ThrowIfNull(valueFactory);
            }

            _factory = valueFactory;
            _state   = LazyHelper.Create(mode, useDefaultConstructor);
        }