다음을 통해 공유


PropertyCollection.GetOrCreateSingletonProperty Method

Definition

Overloads

GetOrCreateSingletonProperty<T>(Func<T>)

Gets or creates a property of type T from the property collection. If there is already a property of that type, it returns the existing property. Otherwise, it uses creator to create an instance of that type.

GetOrCreateSingletonProperty<T>(Object, Func<T>)

Gets or creates a property of type T from the property collection. If there is already a property with the specified key, returns the existing property. Otherwise, uses creator to create an instance of that type and add it to the collection with the specified key.

GetOrCreateSingletonProperty<T>(Func<T>)

Gets or creates a property of type T from the property collection. If there is already a property of that type, it returns the existing property. Otherwise, it uses creator to create an instance of that type.

public:
generic <typename T>
 where T : class T GetOrCreateSingletonProperty(Func<T> ^ creator);
public T GetOrCreateSingletonProperty<T> (Func<T> creator) where T : class;
member this.GetOrCreateSingletonProperty : Func<'T (requires 'T : null)> -> 'T (requires 'T : null)
Public Function GetOrCreateSingletonProperty(Of T As Class) (creator As Func(Of T)) As T

Type Parameters

T

The type of the property.

Parameters

creator
Func<T>

The delegate used to create the property (if needed).

Returns

T

An instance of the property.

Remarks

The key used in the property collection will be typeof(T).

Applies to

GetOrCreateSingletonProperty<T>(Object, Func<T>)

Gets or creates a property of type T from the property collection. If there is already a property with the specified key, returns the existing property. Otherwise, uses creator to create an instance of that type and add it to the collection with the specified key.

public:
generic <typename T>
 where T : class T GetOrCreateSingletonProperty(System::Object ^ key, Func<T> ^ creator);
public T GetOrCreateSingletonProperty<T> (object key, Func<T> creator) where T : class;
member this.GetOrCreateSingletonProperty : obj * Func<'T (requires 'T : null)> -> 'T (requires 'T : null)
Public Function GetOrCreateSingletonProperty(Of T As Class) (key As Object, creator As Func(Of T)) As T

Type Parameters

T

The type of the property.

Parameters

key
Object

The key of the property to get or create.

creator
Func<T>

The delegate used to create the property (if needed).

Returns

T

The property that was requested.

Applies to