/// <summary>
        /// Export only if type is not exported
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="configuration"></param>
        /// <param name="type"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public static IFluentExportInstanceConfiguration <T> IfNotRegistered <T>(
            this IFluentExportInstanceConfiguration <T> configuration, Type type, object key = null)
        {
            var activationStrategyProvider = configuration as IActivationStrategyProvider;

            return(configuration.OnlyIf(block => !block.IsExported(type, key, activationStrategyProvider?.GetStrategy() as ICompiledExportStrategy)));
        }
Exemplo n.º 2
0
        private static IFluentExportInstanceConfiguration <T> ConfigureLifetime <T>(this IFluentExportInstanceConfiguration <T> configuration, ServiceLifetime lifecycleKind)
        {
            switch (lifecycleKind)
            {
            case ServiceLifetime.Scoped:
                return(configuration.Lifestyle.SingletonPerScope());

            case ServiceLifetime.Singleton:
                return(configuration.Lifestyle.Singleton());
            }

            return(configuration);
        }