Catel.IoC.ServiceLocator.RegisterType C# (CSharp) Method

RegisterType() public method

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.
return void
        public void RegisterType(Type serviceType, Func<ServiceLocatorRegistration, object> createServiceFunc, object tag = null, RegistrationType registrationType = RegistrationType.Singleton, bool registerIfAlreadyRegistered = true)
        {
            Argument.IsNotNull("createServiceFunc", createServiceFunc);

            RegisterType(serviceType, null, tag, registrationType, registerIfAlreadyRegistered, this, createServiceFunc);
        }

Same methods

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

Usage Example

コード例 #1
0
        public override void Prepare()
        {
            var serviceLocator = new ServiceLocator();

            serviceLocator.RegisterType<ISingleton, Singleton>(RegistrationType.Singleton);

            serviceLocator.RegisterType<ITransient, Transient>(RegistrationType.Transient);

            serviceLocator.RegisterType<ICombined, Combined>(RegistrationType.Transient);

            container = serviceLocator;
        }
All Usage Examples Of Catel.IoC.ServiceLocator::RegisterType