/// <summary> /// Registers the specified implementation type. /// </summary> /// <typeparam name="TService">The type of the service.</typeparam> /// <param name="implementationType">Type of the implementation.</param> public void Register <TService>(Type implementationType) where TService : class { var b = SetLifetime(ObjectDefinitionBuilder.RootObjectDefinition(_factory, implementationType)); _container.RegisterObjectDefinition(SpringServiceLocator.GetName(implementationType), b.ObjectDefinition); }
/// <summary> /// Registers the specified service type. /// </summary> /// <param name="serviceType">Type of the service.</param> /// <param name="factoryMethod">The factory method.</param> public void Register(Type serviceType, Func <IServiceLocator, object> factoryMethod) { EnsureTransientLifestyle(); Func <object> func = () => factoryMethod(_parent); _container.ObjectFactory.RegisterSingleton(SpringServiceLocator.GetName(serviceType), func); }
// register method /// <summary> /// Registers the specified factory method. /// </summary> /// <typeparam name="TService">The type of the service.</typeparam> /// <param name="factoryMethod">The factory method.</param> public void Register <TService>(Func <IServiceLocator, TService> factoryMethod) where TService : class { EnsureTransientLifestyle(); Func <TService> func = () => factoryMethod(_parent); _container.ObjectFactory.RegisterSingleton(SpringServiceLocator.GetName(typeof(TService)), func); }
// register implementation /// <summary> /// Registers this instance. /// </summary> /// <typeparam name="TService">The type of the service.</typeparam> /// <typeparam name="TImplementation">The type of the implementation.</typeparam> public void Register <TService, TImplementation>() where TService : class where TImplementation : class, TService { var b = SetLifetime(ObjectDefinitionBuilder.RootObjectDefinition(_factory, typeof(TImplementation))); _container.RegisterObjectDefinition(SpringServiceLocator.GetName(typeof(TImplementation)), b.ObjectDefinition); }
/// <summary> /// Registers the instance. /// </summary> /// <param name="serviceType">Type of the service.</param> /// <param name="instance">The instance.</param> public void RegisterInstance(Type serviceType, object instance) { EnsureTransientLifestyle(); _container.ObjectFactory.RegisterSingleton(SpringServiceLocator.GetName(serviceType), instance); }
// register instance /// <summary> /// Registers the instance. /// </summary> /// <typeparam name="TService">The type of the service.</typeparam> /// <param name="instance">The instance.</param> public void RegisterInstance <TService>(TService instance) where TService : class { EnsureTransientLifestyle(); _container.ObjectFactory.RegisterSingleton(SpringServiceLocator.GetName(typeof(TService)), instance); }
/// <summary> /// Registers the specified service type. /// </summary> /// <param name="serviceType">Type of the service.</param> public void Register(Type serviceType) { var b = SetLifetime(ObjectDefinitionBuilder.RootObjectDefinition(_factory, serviceType)); _container.RegisterObjectDefinition(SpringServiceLocator.GetName(serviceType), b.ObjectDefinition); }