/// <summary> /// /// </summary> /// <param name="serviceType"></param> /// <param name="implementationType"></param> /// <param name="lifeCycle"></param> public void Register(Type serviceType, Type implementationType, MigrateServiceLifeCycle lifeCycle = MigrateServiceLifeCycle.Singleton) { var componentRegistration = Component.For(serviceType).ImplementedBy(implementationType).IsDefault(); if (lifeCycle == MigrateServiceLifeCycle.Singleton) { componentRegistration = componentRegistration.LifestyleSingleton(); } if (lifeCycle == MigrateServiceLifeCycle.Transient) { componentRegistration = componentRegistration.LifestyleTransient(); } Container.Register(componentRegistration); }
/// <summary> /// /// </summary> /// <typeparam name="TService"></typeparam> /// <param name="lifeCycle"></param> public void Register <TService>(MigrateServiceLifeCycle lifeCycle = MigrateServiceLifeCycle.Singleton) where TService : class { Register(typeof(TService), typeof(TService), lifeCycle); }
/// <summary> /// /// </summary> /// <typeparam name="TService"></typeparam> /// <typeparam name="TImplementation"></typeparam> /// <param name="lifeCycle"></param> public void Register <TService, TImplementation>(MigrateServiceLifeCycle lifeCycle = MigrateServiceLifeCycle.Singleton) where TService : class where TImplementation : class, TService { Register(typeof(TService), typeof(TImplementation), lifeCycle); }