Provides support for lazy initialization.
More...
|
| Lazy () |
| Initializes a new instance of the T:System.Lazy`1 class. When lazy initialization occurs, the default constructor of the target type is used. More...
|
|
| Lazy (Func< T > valueFactory) |
| Initializes a new instance of the T:System.Lazy`1 class. When lazy initialization occurs, the specified initialization function is used. More...
|
|
| Lazy? (bool isThreadSafe) |
| Initializes a new instance of the T:System.Lazy`1 class. When lazy initialization occurs, the default constructor of the target type and the specified initialization mode are used. More...
|
|
| Lazy (LazyThreadSafetyMode mode) |
| Initializes a new instance of the T:System.Lazy`1 class that uses the default constructor of T and the specified thread-safety mode. More...
|
|
| Lazy? (Func< T > valueFactory, bool isThreadSafe) |
| Initializes a new instance of the T:System.Lazy`1 class. When lazy initialization occurs, the specified initialization function and initialization mode are used. More...
|
|
| Lazy (Func< T > valueFactory, LazyThreadSafetyMode mode) |
| Initializes a new instance of the T:System.Lazy`1 class that uses the specified initialization function and thread-safety mode. More...
|
|
override string | ToString () |
| Creates and returns a string representation of the P:System.Lazy`1.Value property for this instance. More...
|
|
|
bool | IsValueCreated [get] |
| Gets a value that indicates whether a value has been created for this T:System.Lazy`1 instance. More...
|
|
T | Value [get] |
| Gets the lazily initialized value of the current T:System.Lazy`1 instance. More...
|
|
Provides support for lazy initialization.
- Template Parameters
-
T | The type of object that is being lazily initialized. |
Definition at line 18 of file Lazy.cs.
◆ Lazy() [1/4]
Initializes a new instance of the T:System.Lazy`1 class. When lazy initialization occurs, the default constructor of the target type is used.
Definition at line 128 of file Lazy.cs.
◆ Lazy() [2/4]
Initializes a new instance of the T:System.Lazy`1 class. When lazy initialization occurs, the specified initialization function is used.
- Parameters
-
valueFactory | The delegate that is invoked to produce the lazily initialized value when it is needed. |
- Exceptions
-
T:System.ArgumentNullException | valueFactory is null . |
Definition at line 138 of file Lazy.cs.
◆ Lazy() [3/4]
Initializes a new instance of the T:System.Lazy`1 class that uses the default constructor of T and the specified thread-safety mode.
- Parameters
-
mode | One of the enumeration values that specifies the thread safety mode. |
- Exceptions
-
T:System.ArgumentOutOfRangeException | mode contains an invalid value. |
Definition at line 157 of file Lazy.cs.
◆ Lazy() [4/4]
Initializes a new instance of the T:System.Lazy`1 class that uses the specified initialization function and thread-safety mode.
- Parameters
-
valueFactory | The delegate that is invoked to produce the lazily initialized value when it is needed. |
mode | One of the enumeration values that specifies the thread safety mode. |
- Exceptions
-
T:System.ArgumentOutOfRangeException | mode contains an invalid value. |
T:System.ArgumentNullException | valueFactory is null . |
Definition at line 182 of file Lazy.cs.
◆ Lazy?() [1/2]
Initializes a new instance of the T:System.Lazy`1 class. When lazy initialization occurs, the default constructor of the target type and the specified initialization mode are used.
- Parameters
-
isThreadSafe | true to make this instance usable concurrently by multiple threads; false to make the instance usable by only one thread at a time. |
Definition at line 147 of file Lazy.cs.
◆ Lazy?() [2/2]
Initializes a new instance of the T:System.Lazy`1 class. When lazy initialization occurs, the specified initialization function and initialization mode are used.
- Parameters
-
valueFactory | The delegate that is invoked to produce the lazily initialized value when it is needed. |
isThreadSafe | true to make this instance usable concurrently by multiple threads; false to make this instance usable by only one thread at a time. |
- Exceptions
-
T:System.ArgumentNullException | valueFactory is null . |
Definition at line 169 of file Lazy.cs.
◆ ToString()
Creates and returns a string representation of the P:System.Lazy`1.Value property for this instance.
- Returns
- The result of calling the M:System.Object.ToString method on the P:System.Lazy`1.Value property for this instance, if the value has been created (that is, if the P:System.Lazy`1.IsValueCreated property returns
true
). Otherwise, a string indicating that the value has not been created.
- Exceptions
-
T:System.NullReferenceException | The P:System.Lazy`1.Value property is null . |
Definition at line 217 of file Lazy.cs.
◆ IsValueCreated
Gets a value that indicates whether a value has been created for this T:System.Lazy`1 instance.
- Returns
true
if a value has been created for this T:System.Lazy`1 instance; otherwise, false
.
Definition at line 86 of file Lazy.cs.
◆ Value
Gets the lazily initialized value of the current T:System.Lazy`1 instance.
- Returns
- The lazily initialized value of the current T:System.Lazy`1 instance.
- Exceptions
-
T:System.MemberAccessException | The T:System.Lazy`1 instance is initialized to use the default constructor of the type that is being lazily initialized, and permissions to access the constructor are missing. |
T:System.MissingMemberException | The T:System.Lazy`1 instance is initialized to use the default constructor of the type that is being lazily initialized, and that type does not have a public, parameterless constructor. |
T:System.InvalidOperationException | The initialization function tries to access P:System.Lazy`1.Value on this instance. |
Definition at line 106 of file Lazy.cs.
The documentation for this class was generated from the following file: