Lazy<T,TMetadata> Constructors

Definition

Initializes a new instance of the Lazy<T,TMetadata> class.

Overloads

Lazy<T,TMetadata>(TMetadata)

Initializes a new instance of the Lazy<T,TMetadata> class with the specified metadata.

Lazy<T,TMetadata>(Func<T>, TMetadata)

Initializes a new instance of the Lazy<T,TMetadata> class with the specified metadata that uses the specified function to get the referenced object.

Lazy<T,TMetadata>(TMetadata, Boolean)

Initializes a new instance of the Lazy<T,TMetadata> class with the specified metadata and thread safety value.

Lazy<T,TMetadata>(TMetadata, LazyThreadSafetyMode)

Initializes a new instance of the Lazy<T,TMetadata> class with the specified metadata and thread synchronization mode.

Lazy<T,TMetadata>(Func<T>, TMetadata, Boolean)

Initializes a new instance of the Lazy<T,TMetadata> class with the specified metadata and thread safety value that uses the specified function to get the referenced object.

Lazy<T,TMetadata>(Func<T>, TMetadata, LazyThreadSafetyMode)

Initializes a new instance of the Lazy<T,TMetadata> class with the specified metadata and thread synchronization mode that uses the specified function to get the referenced object.

Lazy<T,TMetadata>(TMetadata)

Source:
LazyOfTTMetadata.cs
Source:
LazyOfTTMetadata.cs
Source:
LazyOfTTMetadata.cs

Initializes a new instance of the Lazy<T,TMetadata> class with the specified metadata.

public Lazy (TMetadata metadata);

Parameters

metadata
TMetadata

The metadata associated with the referenced object.

Applies to

.NET 9 и другие версии
Продукт Версии
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

Lazy<T,TMetadata>(Func<T>, TMetadata)

Source:
LazyOfTTMetadata.cs
Source:
LazyOfTTMetadata.cs
Source:
LazyOfTTMetadata.cs

Initializes a new instance of the Lazy<T,TMetadata> class with the specified metadata that uses the specified function to get the referenced object.

public Lazy (Func<T> valueFactory, TMetadata metadata);

Parameters

valueFactory
Func<T>

A function that returns the referenced object.

metadata
TMetadata

The metadata associated with the referenced object.

Applies to

.NET 9 и другие версии
Продукт Версии
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

Lazy<T,TMetadata>(TMetadata, Boolean)

Source:
LazyOfTTMetadata.cs
Source:
LazyOfTTMetadata.cs
Source:
LazyOfTTMetadata.cs

Initializes a new instance of the Lazy<T,TMetadata> class with the specified metadata and thread safety value.

public Lazy (TMetadata metadata, bool isThreadSafe);

Parameters

metadata
TMetadata

The metadata associated with the referenced object.

isThreadSafe
Boolean

Indicates whether the Lazy<T,TMetadata> object that is created will be thread-safe.

Applies to

.NET 9 и другие версии
Продукт Версии
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

Lazy<T,TMetadata>(TMetadata, LazyThreadSafetyMode)

Source:
LazyOfTTMetadata.cs
Source:
LazyOfTTMetadata.cs
Source:
LazyOfTTMetadata.cs

Initializes a new instance of the Lazy<T,TMetadata> class with the specified metadata and thread synchronization mode.

public Lazy (TMetadata metadata, System.Threading.LazyThreadSafetyMode mode);

Parameters

metadata
TMetadata

The metadata associated with the referenced object.

mode
LazyThreadSafetyMode

The thread synchronization mode.

Remarks

See LazyThreadSafetyMode for more information on thread synchronization and Lazy<T,TMetadata>.

Applies to

.NET 9 и другие версии
Продукт Версии
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

Lazy<T,TMetadata>(Func<T>, TMetadata, Boolean)

Source:
LazyOfTTMetadata.cs
Source:
LazyOfTTMetadata.cs
Source:
LazyOfTTMetadata.cs

Initializes a new instance of the Lazy<T,TMetadata> class with the specified metadata and thread safety value that uses the specified function to get the referenced object.

public Lazy (Func<T> valueFactory, TMetadata metadata, bool isThreadSafe);

Parameters

valueFactory
Func<T>

A function that returns the referenced object.

metadata
TMetadata

The metadata associated with the referenced object.

isThreadSafe
Boolean

Indicates whether the Lazy<T,TMetadata> object that is created will be thread-safe.

Applies to

.NET 9 и другие версии
Продукт Версии
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

Lazy<T,TMetadata>(Func<T>, TMetadata, LazyThreadSafetyMode)

Source:
LazyOfTTMetadata.cs
Source:
LazyOfTTMetadata.cs
Source:
LazyOfTTMetadata.cs

Initializes a new instance of the Lazy<T,TMetadata> class with the specified metadata and thread synchronization mode that uses the specified function to get the referenced object.

public Lazy (Func<T> valueFactory, TMetadata metadata, System.Threading.LazyThreadSafetyMode mode);

Parameters

valueFactory
Func<T>

A function that returns the referenced object.

metadata
TMetadata

The metadata associated with the referenced object.

mode
LazyThreadSafetyMode

The thread synchronization mode.

Remarks

See LazyThreadSafetyMode for more information on thread synchronization and Lazy<T,TMetadata>.

Applies to

.NET 9 и другие версии
Продукт Версии
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0