Cocktail Help Reference
GetInstance(Type,String,CreationPolicy) Method
See Also  Send Feedback
Cocktail Assembly > Cocktail Namespace > Composition Class > GetInstance Method : GetInstance(Type,String,CreationPolicy) Method



serviceType
The type of the requested instance.
key
The contract name of the instance requested. If no contract name is specified, the type will be used.
requiredCreationPolicy
Optionally specify whether the returned instance should be a shared, non-shared or any instance.

Glossary Item Box

Returns an instance of the custom implementation for the provided type or contract name.

Syntax

Visual Basic (Declaration) 
Public Overloads Shared Function GetInstance( _
   ByVal serviceType As Type, _
   ByVal key As String, _
   Optional ByVal requiredCreationPolicy As CreationPolicy _
) As Object
Visual Basic (Usage)Copy Code
Dim serviceType As Type
Dim key As String
Dim requiredCreationPolicy As CreationPolicy
Dim value As Object
 
value = Composition.GetInstance(serviceType, key, requiredCreationPolicy)
C# 
public static object GetInstance( 
   Type serviceType,
   string key,
   CreationPolicy requiredCreationPolicy
)
C++/CLI 
public:
static Object^ GetInstance( 
   Type^ serviceType,
   String^ key,
   CreationPolicy requiredCreationPolicy
) 

Parameters

serviceType
The type of the requested instance.
key
The contract name of the instance requested. If no contract name is specified, the type will be used.
requiredCreationPolicy
Optionally specify whether the returned instance should be a shared, non-shared or any instance.

Return Value

The requested instance.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2012 All Rights Reserved.