mscorlib(4.0.0.0) API with additions
System.Threading.LazyInitializer Class Reference

Provides lazy initialization routines. More...

Static Public Member Functions

static T EnsureInitialized< T > (ref T target)
 Initializes a target reference type with the type's default constructor if it hasn't already been initialized. More...
 
static T EnsureInitialized< T > (ref T target, Func< T > valueFactory)
 Initializes a target reference type by using a specified function if it hasn't already been initialized. More...
 
static T EnsureInitialized< T > (ref T target, ref bool initialized, ref object syncLock)
 Initializes a target reference or value type with its default constructor if it hasn't already been initialized. More...
 
static T EnsureInitialized< T > (ref T target, ref bool initialized, ref object syncLock, Func< T > valueFactory)
 Initializes a target reference or value type by using a specified function if it hasn't already been initialized. More...
 

Detailed Description

Provides lazy initialization routines.

Definition at line 8 of file LazyInitializer.cs.

Member Function Documentation

◆ EnsureInitialized< T >() [1/4]

static T System.Threading.LazyInitializer.EnsureInitialized< T > ( ref T  target)
static

Initializes a target reference type with the type's default constructor if it hasn't already been initialized.

Parameters
targetA reference of type T to initialize if it has not already been initialized.
Template Parameters
TThe type of the reference to be initialized.
Returns
The initialized reference of type T .
Exceptions
T:System.MemberAccessExceptionPermissions to access the constructor of type T were missing.
T:System.MissingMemberExceptionType T does not have a default constructor.
Type Constraints
T :class 

Definition at line 17 of file LazyInitializer.cs.

◆ EnsureInitialized< T >() [2/4]

static T System.Threading.LazyInitializer.EnsureInitialized< T > ( ref T  target,
Func< T >  valueFactory 
)
static

Initializes a target reference type by using a specified function if it hasn't already been initialized.

Parameters
targetThe reference of type T to initialize if it hasn't already been initialized.
valueFactoryThe function that is called to initialize the reference.
Template Parameters
TThe reference type of the reference to be initialized.
Returns
The initialized value of type T .
Exceptions
T:System.MissingMemberExceptionType T does not have a default constructor.
T:System.InvalidOperationExceptionvalueFactory returned null (Nothing in Visual Basic).
Type Constraints
T :class 

Definition at line 35 of file LazyInitializer.cs.

◆ EnsureInitialized< T >() [3/4]

static T System.Threading.LazyInitializer.EnsureInitialized< T > ( ref T  target,
ref bool  initialized,
ref object  syncLock 
)
static

Initializes a target reference or value type with its default constructor if it hasn't already been initialized.

Parameters
targetA reference or value of type T to initialize if it hasn't already been initialized.
initializedA reference to a Boolean value that determines whether the target has already been initialized.
syncLockA reference to an object used as the mutually exclusive lock for initializing target . If syncLock is null, a new object will be instantiated.
Template Parameters
TThe type of the reference to be initialized.
Returns
The initialized value of type T .
Exceptions
T:System.MemberAccessExceptionPermissions to access the constructor of type T were missing.
T:System.MissingMemberExceptionType T does not have a default constructor.

Definition at line 64 of file LazyInitializer.cs.

◆ EnsureInitialized< T >() [4/4]

static T System.Threading.LazyInitializer.EnsureInitialized< T > ( ref T  target,
ref bool  initialized,
ref object  syncLock,
Func< T >  valueFactory 
)
static

Initializes a target reference or value type by using a specified function if it hasn't already been initialized.

Parameters
targetA reference or value of type T to initialize if it hasn't already been initialized.
initializedA reference to a Boolean value that determines whether the target has already been initialized.
syncLockA reference to an object used as the mutually exclusive lock for initializing target . If syncLock is null, a new object will be instantiated.
valueFactoryThe function that is called to initialize the reference or value.
Template Parameters
TThe type of the reference to be initialized.
Returns
The initialized value of type T .
Exceptions
T:System.MemberAccessExceptionPermissions to access the constructor of type T were missing.
T:System.MissingMemberExceptionType T does not have a default constructor.

Definition at line 83 of file LazyInitializer.cs.


The documentation for this class was generated from the following file: