Skip to content

Composer

QuantConnect.Util.Composer

Composer()

Bases: Object

Provides methods for obtaining exported MEF instances

Initializes a new instance of the Composer class. This type is a light wrapper on top of an MEF CompositionContainer

INSTANCE

INSTANCE: Composer

Gets the singleton instance

add_part

add_part(
    instance: QuantConnect_Util_Composer_AddPart_T,
) -> None

Adds the specified instance to this instance to allow it to be recalled via GetExportedValueByTypeName

Parameters:

Name Type Description Default
instance QuantConnect_Util_Composer_AddPart_T

The instance to add

required

get_exported_types

get_exported_types() -> Sequence[Type]

Will return all loaded types that are assignable to T type

get_exported_value_by_type_name

get_exported_value_by_type_name(
    type_name: str, force_type_name_on_existing: bool = True
) -> (
    QuantConnect_Util_Composer_GetExportedValueByTypeName_T
)

Extension method to searches the composition container for an export that has a matching type name. This function will first try to match on Type.AssemblyQualifiedName, then Type.FullName, and finally on Type.Name

Parameters:

Name Type Description Default
type_name str

The name of the type to find. This can be an assembly qualified name, a full name, or just the type's name

required
force_type_name_on_existing bool

When false, if any existing instance of type T is found, it will be returned even if type name doesn't match.

True

Returns:

Type Description
QuantConnect_Util_Composer_GetExportedValueByTypeName_T

The export instance.

get_exported_values

get_exported_values() -> (
    Sequence[QuantConnect_Util_Composer_GetExportedValues_T]
)

Gets all exports of type T

get_part

get_part() -> QuantConnect_Util_Composer_GetPart_T
get_part(
    filter: Callable[
        [QuantConnect_Util_Composer_GetPart_T], bool
    ],
) -> QuantConnect_Util_Composer_GetPart_T

Gets the first type T instance if any

get_parts

get_parts() -> (
    Sequence[QuantConnect_Util_Composer_GetParts_T]
)

Gets all parts of type T instance if any

single

single(
    predicate: Callable[
        [QuantConnect_Util_Composer_Single_T], bool
    ],
) -> QuantConnect_Util_Composer_Single_T

Gets the export matching the predicate

Parameters:

Name Type Description Default
predicate Callable[[QuantConnect_Util_Composer_Single_T], bool]

Function used to pick which imported instance to return, if null the first instance is returned

required

Returns:

Type Description
QuantConnect_Util_Composer_Single_T

The only export matching the specified predicate.

reset

reset() -> None

Clears the cache of exported values, causing new instances to be created.