Lean
$LEAN_TAG$
|
Provides methods for obtaining exported MEF instances More...
Public Member Functions | |
Composer () | |
Initializes a new instance of the Composer class. This type is a light wrapper on top of an MEF CompositionContainer More... | |
T | Single< T > (Func< T, bool > predicate) |
Gets the export matching the predicate More... | |
void | AddPart< T > (T instance) |
Adds the specified instance to this instance to allow it to be recalled via GetExportedValueByTypeName More... | |
T | GetPart< T > () |
Gets the first type T instance if any More... | |
T | GetPart< T > (Func< T, bool > filter) |
Gets the first type T instance if any More... | |
IEnumerable< Type > | GetExportedTypes< T > () |
Will return all loaded types that are assignable to T type More... | |
T | GetExportedValueByTypeName< T > (string typeName, bool forceTypeNameOnExisting=true) |
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 More... | |
IEnumerable< T > | GetExportedValues< T > () |
Gets all exports of type T More... | |
void | Reset () |
Clears the cache of exported values, causing new instances to be created. More... | |
Static Public Attributes | |
static Composer | Instance => LazyComposer.Value |
Gets the singleton instance More... | |
Provides methods for obtaining exported MEF instances
Definition at line 38 of file Composer.cs.
QuantConnect.Util.Composer.Composer | ( | ) |
Initializes a new instance of the Composer class. This type is a light wrapper on top of an MEF CompositionContainer
Definition at line 60 of file Composer.cs.
T QuantConnect.Util.Composer.Single< T > | ( | Func< T, bool > | predicate | ) |
Gets the export matching the predicate
predicate | Function used to pick which imported instance to return, if null the first instance is returned |
Definition at line 169 of file Composer.cs.
void QuantConnect.Util.Composer.AddPart< T > | ( | T | instance | ) |
Adds the specified instance to this instance to allow it to be recalled via GetExportedValueByTypeName
T | The contract type |
instance | The instance to add |
Definition at line 184 of file Composer.cs.
T QuantConnect.Util.Composer.GetPart< T > | ( | ) |
Gets the first type T instance if any
T | The contract type |
Definition at line 205 of file Composer.cs.
T QuantConnect.Util.Composer.GetPart< T > | ( | Func< T, bool > | filter | ) |
Gets the first type T instance if any
T | The contract type |
Definition at line 214 of file Composer.cs.
IEnumerable<Type> QuantConnect.Util.Composer.GetExportedTypes< T > | ( | ) |
Will return all loaded types that are assignable to T type
T | : | class |
Definition at line 230 of file Composer.cs.
T QuantConnect.Util.Composer.GetExportedValueByTypeName< T > | ( | string | typeName, |
bool | forceTypeNameOnExisting = true |
||
) |
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
This method will not throw if multiple types are found matching the name, it will just return the first one it finds.
T | The type of the export |
typeName | The name of the type to find. This can be an assembly qualified name, a full name, or just the type's name |
forceTypeNameOnExisting | When false, if any existing instance of type T is found, it will be returned even if type name doesn't match. This is useful in cases where a single global instance is desired, like for IDataAggregator |
T | : | class |
Definition at line 257 of file Composer.cs.
IEnumerable<T> QuantConnect.Util.Composer.GetExportedValues< T > | ( | ) |
Gets all exports of type T
Definition at line 368 of file Composer.cs.
void QuantConnect.Util.Composer.Reset | ( | ) |
Clears the cache of exported values, causing new instances to be created.
Definition at line 403 of file Composer.cs.
|
static |
Gets the singleton instance
Intentionally using a property so that when its gotten it will trigger the lazy construction which will be after the right configuration is loaded. See GH issue 3258
Definition at line 54 of file Composer.cs.