C# 클래스 Catel.IoC.ServiceLocator

Default implementation of the IServiceLocator interface.
상속: IServiceLocator
파일 보기 프로젝트 열기: Catel/Catel 1 사용 예제들

Private Properties

프로퍼티 타입 설명
CompleteTypeRequestPathIfRequired void
CreateServiceInstance object
IServiceProvider object
RegisterInstance void
RegisterType void
ResolveTypeFromKnownContainer object
ThrowTypeNotRegisteredException void

공개 메소드들

메소드 설명
AreAllTypesRegistered ( ) : bool

Determines whether all the specified types are registered with the service locator.

Note that this method is written for optimalization by the TypeFactory. This means that the TypeFactory does not need to call the ServiceLocator several times to construct a single type using dependency injection. Only use this method if you know what you are doing, otherwise use the IsTypeRegistered instead.

Dispose ( ) : void

Disposes this instance and all registered instances.

GetRegistrationInfo ( Type serviceType, object tag = null ) : Catel.IoC.RegistrationInfo

Gets the registration info about the specified type.

IsTypeRegistered ( Type serviceType, object tag = null ) : bool

Determines whether the specified service type is registered.

Note that the actual implementation lays in the hands of the IoC technique being used.

IsTypeRegisteredAsSingleton ( Type serviceType, object tag = null ) : bool

Determines whether the specified service type is registered as singleton.

RegisterInstance ( Type serviceType, object instance, object tag = null ) : void

Registers a specific instance of a service.

RegisterType ( Type serviceType, object>.Func createServiceFunc, object tag = null, RegistrationType registrationType = RegistrationType.Singleton, bool registerIfAlreadyRegistered = true ) : void

Registers an implementation of a service using a create type callback, but only if the type is not yet registered.

Note that the actual implementation lays in the hands of the IoC technique being used.

RegisterType ( Type serviceType, Type serviceImplementationType, object tag = null, RegistrationType registrationType = RegistrationType.Singleton, bool registerIfAlreadyRegistered = true ) : void

Registers an implementation of a service, but only if the type is not yet registered.

Note that the actual implementation lays in the hands of the IoC technique being used.

RemoveAllTypes ( Type serviceType ) : void

Removes all registered types of a certain service type.

RemoveType ( Type serviceType, object tag = null ) : void

Removes the registered type with the specific tag.

ResolveAllTypes ( ) : object[]

Resolves all the specified types.

Note that this method is written for optimalization by the TypeFactory. This means that the TypeFactory does not need to call the ServiceLocator several times to construct a single type using dependency injection. Only use this method if you know what you are doing, otherwise use the ResolveType instead.

ResolveType ( Type serviceType, object tag = null ) : object

Resolves an instance of the type registered on the service.

Note that the actual implementation lays in the hands of the IoC technique being used.

ResolveTypes ( Type serviceType ) : IEnumerable

Resolves all instances of the type registered on the service.

Note that the actual implementation lays in the hands of the IoC technique being used.

ServiceLocator ( ) : System

Initializes a new instance of the ServiceLocator class.

비공개 메소드들

메소드 설명
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.

CreateServiceInstance ( Catel.IoC.ServiceLocatorRegistration registration ) : object

Creates the service instance.

IServiceProvider ( Type serviceType ) : object

Gets the service object of the specified type.

RegisterInstance ( Type serviceType, object instance, object tag, object originalContainer ) : void

Registers a specific instance of an service.

RegisterType ( Type serviceType, Type serviceImplementationType, object tag, RegistrationType registrationType, bool registerIfAlreadyRegistered, object originalContainer, object>.Func createServiceFunc ) : void

Registers the specific implementing type for the service type.

ResolveTypeFromKnownContainer ( Type serviceType, object tag ) : object

Resolves the type from a known container.

ThrowTypeNotRegisteredException ( Type type, string message = null ) : void

Throws the TypeNotRegisteredException but will also reset the current type request path.

메소드 상세

AreAllTypesRegistered() 공개 메소드

Determines whether all the specified types are registered with the service locator.
Note that this method is written for optimalization by the TypeFactory. This means that the TypeFactory does not need to call the ServiceLocator several times to construct a single type using dependency injection. Only use this method if you know what you are doing, otherwise use the IsTypeRegistered instead.
The is null.
public AreAllTypesRegistered ( ) : bool
리턴 bool

Dispose() 공개 메소드

Disposes this instance and all registered instances.
public Dispose ( ) : void
리턴 void

GetRegistrationInfo() 공개 메소드

Gets the registration info about the specified type.
The is null.
public GetRegistrationInfo ( Type serviceType, object tag = null ) : Catel.IoC.RegistrationInfo
serviceType System.Type Type of the service.
tag object The tag the service is registered with. The default value is null.
리턴 Catel.IoC.RegistrationInfo

IsTypeRegistered() 공개 메소드

Determines whether the specified service type is registered.
Note that the actual implementation lays in the hands of the IoC technique being used.
The is null.
public IsTypeRegistered ( Type serviceType, object tag = null ) : bool
serviceType System.Type The type of the service.
tag object The tag to register the service with. The default value is null.
리턴 bool

IsTypeRegisteredAsSingleton() 공개 메소드

Determines whether the specified service type is registered as singleton.
public IsTypeRegisteredAsSingleton ( Type serviceType, object tag = null ) : bool
serviceType System.Type The service type.
tag object The tag to register the service with. The default value is null.
리턴 bool

RegisterInstance() 공개 메소드

Registers a specific instance of a service.
The is null. The is null. The is not of the right type.
public RegisterInstance ( Type serviceType, object instance, object tag = null ) : void
serviceType System.Type Type of the service.
instance object The instance.
tag object The tag to register the service with. The default value is null.
리턴 void

RegisterType() 공개 메소드

Registers an implementation of a service using a create type callback, but only if the type is not yet registered.
Note that the actual implementation lays in the hands of the IoC technique being used.
If is null. If is null.
public RegisterType ( Type serviceType, object>.Func createServiceFunc, object tag = null, RegistrationType registrationType = RegistrationType.Singleton, bool registerIfAlreadyRegistered = true ) : void
serviceType System.Type The type of the service.
createServiceFunc object>.Func The create service function.
tag object The tag to register the service with. The default value is null.
registrationType RegistrationType The registration type. The default value is .
registerIfAlreadyRegistered bool If set to true, an older type registration is overwritten by this new one.
리턴 void

RegisterType() 공개 메소드

Registers an implementation of a service, but only if the type is not yet registered.
Note that the actual implementation lays in the hands of the IoC technique being used.
If is null. If is null.
public RegisterType ( Type serviceType, Type serviceImplementationType, object tag = null, RegistrationType registrationType = RegistrationType.Singleton, bool registerIfAlreadyRegistered = true ) : void
serviceType System.Type The type of the service.
serviceImplementationType System.Type The type of the implementation.
tag object The tag to register the service with. The default value is null.
registrationType RegistrationType The registration type. The default value is .
registerIfAlreadyRegistered bool If set to true, an older type registration is overwritten by this new one.
리턴 void

RemoveAllTypes() 공개 메소드

Removes all registered types of a certain service type.
The is null.
public RemoveAllTypes ( Type serviceType ) : void
serviceType System.Type The type of the service.
리턴 void

RemoveType() 공개 메소드

Removes the registered type with the specific tag.
The is null.
public RemoveType ( Type serviceType, object tag = null ) : void
serviceType System.Type The type of the service.
tag object The tag of the registered the service. The default value is null.
리턴 void

ResolveAllTypes() 공개 메소드

Resolves all the specified types.
Note that this method is written for optimalization by the TypeFactory. This means that the TypeFactory does not need to call the ServiceLocator several times to construct a single type using dependency injection. Only use this method if you know what you are doing, otherwise use the ResolveType instead.
The is null.
public ResolveAllTypes ( ) : object[]
리턴 object[]

ResolveType() 공개 메소드

Resolves an instance of the type registered on the service.
Note that the actual implementation lays in the hands of the IoC technique being used.
The is null. The type is not found in any container.
public ResolveType ( Type serviceType, object tag = null ) : object
serviceType System.Type The type of the service.
tag object The tag to register the service with. The default value is null.
리턴 object

ResolveTypes() 공개 메소드

Resolves all instances of the type registered on the service.
Note that the actual implementation lays in the hands of the IoC technique being used.
The is null.
public ResolveTypes ( Type serviceType ) : IEnumerable
serviceType System.Type The type of the service.
리턴 IEnumerable

ServiceLocator() 공개 메소드

Initializes a new instance of the ServiceLocator class.
public ServiceLocator ( ) : System
리턴 System