C# Класс Catel.IoC.TypeFactory

Type factory which will cache constructors to ensure the best performance available. This class will automatically watch the IServiceLocator.TypeRegistered event and clear the cache automatically when the event occurs.
Наследование: ITypeFactory
Показать файл Открыть проект

Открытые методы

Метод Описание
ClearCache ( ) : void

Clears the cache of all constructors. This call is normally not necessary since the type factory should keep an eye on the IServiceLocator.TypeRegistered event to invalidate the cache.

CreateInstance ( Type typeToConstruct ) : object

Creates an instance of the specified type using dependency injection.

CreateInstanceWithParameters ( Type typeToConstruct ) : object

Creates an instance of the specified type using the specified parameters as injection values.

CreateInstanceWithParametersAndAutoCompletion ( Type typeToConstruct ) : object

Creates an instance of the specified type using the specified parameters as injection values. This method will also auto-complete any additional dependencies that can be resolved from the IServiceLocator.

CreateInstanceWithParametersAndAutoCompletionWithTag ( Type typeToConstruct, object tag ) : object

Creates an instance of the specified type using the specified parameters as injection values. This method will also auto-complete any additional dependencies that can be resolved from the IServiceLocator.

CreateInstanceWithParametersWithTag ( Type typeToConstruct, object tag ) : object

Creates an instance of the specified type using the specified parameters as injection values.

CreateInstanceWithTag ( Type typeToConstruct, object tag ) : object

Creates an instance of the specified type using dependency injection.

TypeFactory ( IServiceLocator serviceLocator ) : System

Initializes a new instance of the TypeFactory class.

Приватные методы

Метод Описание
CanConstructorBeUsed ( ConstructorInfo constructor, object tag, bool autoCompleteDependencies ) : bool

Determines whether the specified constructor can be used for dependency injection.

CloseCurrentTypeIfRequired ( Catel.IoC.TypeRequestInfo typeRequestInfoForTypeJustConstructed ) : void

Marks the specified type as not being created. If this was the only type being constructed, the type request path will be closed.

CompleteTypeRequestPathIfRequired ( Catel.IoC.TypeRequestInfo typeRequestInfoForTypeJustConstructed ) : void

Completes the type request path by checking if the currently created type is the same as the first type meaning that the type is successfully created and the current type request path can be set to null.

CountSpecialObjects ( ConstructorInfo constructor ) : int

Gets the special objects count for the specific constructor.

CreateInstanceWithSpecifiedParameters ( Type typeToConstruct, object tag, object parameters, bool autoCompleteDependencies, bool preventCircularDependencies = true ) : object

Creates an instance of the specified type using the specified parameters as injection values.

GetConstructorCache ( bool autoCompleteDependencies ) : ConstructorInfo>.Dictionary

Gets the constructor cache depending on whether the dependencies should be auto completed.

GetTypeMetaData ( Type type ) : TypeMetaData

Gets the constructors metadata.

InitializeAfterConstruction ( object obj ) : void

Initializes the created object after its construction.

IsValidParameterValue ( Type parameterType, object parameterValue ) : bool

Determines whether the specified parameter value can be used for the specified parameter type.

OnAssemblyLoaded ( object sender, AssemblyLoadedEventArgs e ) : void

Called when the TypeCache.AssemblyLoaded event occurs.

OnServiceLocatorTypeRegistered ( object sender, Catel.IoC.TypeRegisteredEventArgs eventArgs ) : void

Called when the IServiceLocator.TypeRegistered event occurs.

TryCreateToConstruct ( Type typeToConstruct, ConstructorInfo constructor, object tag, object parameters, bool checkConstructor, bool hasMoreConstructorsLeft ) : object

Tries to create the service with the specified constructor using the specified parameters. This method will not throw an exception when the invocation fails.

Note that this method does not require an implementation of TypeRequestPath because this already has the parameter values and thus cannot lead to invalid circular dependencies.

TypeFactory ( ) : System

Описание методов

ClearCache() публичный Метод

Clears the cache of all constructors. This call is normally not necessary since the type factory should keep an eye on the IServiceLocator.TypeRegistered event to invalidate the cache.
public ClearCache ( ) : void
Результат void

CreateInstance() публичный Метод

Creates an instance of the specified type using dependency injection.
The is null.
public CreateInstance ( Type typeToConstruct ) : object
typeToConstruct System.Type The type to construct.
Результат object

CreateInstanceWithParameters() публичный Метод

Creates an instance of the specified type using the specified parameters as injection values.
The is null.
public CreateInstanceWithParameters ( Type typeToConstruct ) : object
typeToConstruct System.Type The type to construct.
Результат object

CreateInstanceWithParametersAndAutoCompletion() публичный Метод

Creates an instance of the specified type using the specified parameters as injection values. This method will also auto-complete any additional dependencies that can be resolved from the IServiceLocator.
The is null.
public CreateInstanceWithParametersAndAutoCompletion ( Type typeToConstruct ) : object
typeToConstruct System.Type The type to construct.
Результат object

CreateInstanceWithParametersAndAutoCompletionWithTag() публичный Метод

Creates an instance of the specified type using the specified parameters as injection values. This method will also auto-complete any additional dependencies that can be resolved from the IServiceLocator.
The is null.
public CreateInstanceWithParametersAndAutoCompletionWithTag ( Type typeToConstruct, object tag ) : object
typeToConstruct System.Type The type to construct.
tag object The preferred tag when resolving dependencies.
Результат object

CreateInstanceWithParametersWithTag() публичный Метод

Creates an instance of the specified type using the specified parameters as injection values.
The is null.
public CreateInstanceWithParametersWithTag ( Type typeToConstruct, object tag ) : object
typeToConstruct System.Type The type to construct.
tag object The preferred tag when resolving dependencies.
Результат object

CreateInstanceWithTag() публичный Метод

Creates an instance of the specified type using dependency injection.
The is null.
public CreateInstanceWithTag ( Type typeToConstruct, object tag ) : object
typeToConstruct System.Type The type to construct.
tag object The preferred tag when resolving dependencies.
Результат object

TypeFactory() публичный Метод

Initializes a new instance of the TypeFactory class.
The is null.
public TypeFactory ( IServiceLocator serviceLocator ) : System
serviceLocator IServiceLocator The service locator.
Результат System