Partager via


PropertyCollection.GetOrCreateSingletonProperty<T> Method (Object, Func<T>)

Gets or creates a property of type T from the property collection.

Namespace:  Microsoft.VisualStudio.Utilities
Assembly:  Microsoft.VisualStudio.CoreUtility (in Microsoft.VisualStudio.CoreUtility.dll)

Syntax

'Declaration
Public Function GetOrCreateSingletonProperty(Of T As Class) ( _
    key As Object, _
    creator As Func(Of T) _
) As T
public T GetOrCreateSingletonProperty<T>(
    Object key,
    Func<T> creator
)
where T : class
public:
generic<typename T>
where T : ref class
T GetOrCreateSingletonProperty(
    Object^ key, 
    Func<T>^ creator
)
member GetOrCreateSingletonProperty : 
        key:Object * 
        creator:Func<'T> -> 'T  when 'T : not struct
JScript does not support generic types or methods.

Type Parameters

  • T
    The type of the property.

Parameters

  • key
    Type: Object

    The key of the property to get or create.

  • creator
    Type: Func<T>

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

Return Value

Type: T
The property that was requested. If there is already a property with the specified key, returns the existing property. Otherwise, this method uses creator to create an instance of that type and add it to the collection with the specified key.

.NET Framework Security

See Also

Reference

PropertyCollection Class

GetOrCreateSingletonProperty Overload

Microsoft.VisualStudio.Utilities Namespace