Exemplo n.º 1
0
 private void PublicationOnlyViaConstructor(LazyHelper initializer)
 {
     PublicationOnly(initializer, CreateViaDefaultConstructor());
 }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="System.Lazy{T}"/>
 /// class that uses <typeparamref name="T"/>'s default constructor and a specified thread-safety mode.
 /// </summary>
 /// <param name="isThreadSafe">true if this instance should be usable by multiple threads concurrently; false if the instance will only be used by one thread at a time.
 /// </param>
 public Lazy(bool isThreadSafe) :
     this(null, LazyHelper.GetModeFromIsThreadSafe(isThreadSafe), useDefaultConstructor : true)
 {
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="System.Lazy{T}"/> class
 /// that uses a specified initialization function and a specified thread-safety mode.
 /// </summary>
 /// <param name="valueFactory">
 /// The <see cref="System.Func{T}"/> invoked to produce the lazily-initialized value when it is needed.
 /// </param>
 /// <param name="isThreadSafe">true if this instance should be usable by multiple threads concurrently; false if the instance will only be used by one thread at a time.
 /// </param>
 /// <exception cref="System.ArgumentNullException"><paramref name="valueFactory"/> is
 /// a null reference (Nothing in Visual Basic).</exception>
 public Lazy(Func <T> valueFactory, bool isThreadSafe) :
     this(valueFactory, LazyHelper.GetModeFromIsThreadSafe(isThreadSafe), useDefaultConstructor : false)
 {
 }
Exemplo n.º 4
0
 private static T CreateViaDefaultConstructor() => LazyHelper.CreateViaDefaultConstructor <T>();
Exemplo n.º 5
0
 private void ViaConstructor()
 {
     m_value = CreateViaDefaultConstructor();
     _state  = null; // volatile write, must occur after setting _value
 }
Exemplo n.º 6
0
 private static T CreateViaDefaultConstructor()
 {
     return((T)LazyHelper.CreateViaDefaultConstructor(typeof(T)));
 }
Exemplo n.º 7
0
 internal static bool GetIsValueFaulted(LazyHelper state) => state?._exceptionDispatch != null;
Exemplo n.º 8
0
 public static Lazy <T> HookValueFactory <T>(this Lazy <T> lazy, Func <Func <T>, T> valueFactory)
 {
     LazyHelper <T> .HookValueFactory(lazy, valueFactory); return(lazy);
 }