Beispiel #1
0
        /// <summary>
        /// Registers a one or another service implementation depending on whether the IntegrationDb is disabled or not.
        /// </summary>
        /// <typeparam name="TService">The common service interface shared by the implementations.</typeparam>
        /// <typeparam name="TIntegrationDbEnabledImpl">The service implementation to use when we have an IntegrationDb available.</typeparam>
        /// <typeparam name="TIntegrationDbDisabledImpl">The (fallback) service implementation to use when IntegrationDb is disabled.</typeparam>
        public ServicesAdvancedConfiguration Register <TService, TIntegrationDbEnabledImpl, TIntegrationDbDisabledImpl>()
            where TService : class
            where TIntegrationDbEnabledImpl : class, TService
            where TIntegrationDbDisabledImpl : class, TService
        {
            // TODO: Test at denne også erstatter en service som er registreret by convention
            // TODO: Giv mulighed for at påvirke Registration / Singleton / ala public InstanceInstaller(T instance, Action<ComponentRegistration<T>> registration = null)

            _registrations[typeof(TService)] = new Registration(
                kernel => Installer.Service <TService, TIntegrationDbEnabledImpl>(),
                kernel => Installer.Service <TService, TIntegrationDbDisabledImpl>());

            return(this);
        }