public void ProxyFluentExportStrategyConfiguration_AsKeyed(FluentWithCtorConfiguration <int> configuration,
                                                                   IFluentExportStrategyConfiguration strategyConfiguration)
        {
            configuration.AsKeyed(typeof(IBasicService), 'A');

            strategyConfiguration.Received().AsKeyed(typeof(IBasicService), 'A');
        }
Beispiel #2
0
        public void FluentExportMemberConfiguration_Generic_As(FluentExportMemberConfiguration <BasicService> configuration,
                                                               IFluentExportStrategyConfiguration <BasicService> fluentConfiguration)
        {
            configuration.As(typeof(IBasicService));

            fluentConfiguration.Received().As(typeof(IBasicService));
        }
        public void ProxyFluentExportStrategyConfiguration_ExternallyOwned([Locate] FluentWithCtorConfiguration <BasicService, int> configuration,
                                                                           IFluentExportStrategyConfiguration <BasicService> strategyConfiguration)
        {
            configuration.ExternallyOwned();

            strategyConfiguration.Received().ExternallyOwned();
        }
Beispiel #4
0
        public void FluentExportMemberConfiguration_Generic_AsKeyed(FluentExportMemberConfiguration <BasicService> configuration,
                                                                    IFluentExportStrategyConfiguration <BasicService> fluentConfiguration)
        {
            configuration.AsKeyed <IBasicService>("Hello");

            fluentConfiguration.Received().AsKeyed <IBasicService>("Hello");
        }
        public void ProxyFluentExportStrategyConfiguration_WithPriority([Locate] FluentWithCtorConfiguration <BasicService, int> configuration,
                                                                        IFluentExportStrategyConfiguration <BasicService> strategyConfiguration)
        {
            configuration.WithPriority(10);

            strategyConfiguration.Received().WithPriority(10);
        }
        public void ProxyFluentExportStrategyConfiguration_As([Locate] FluentWithCtorConfiguration <BasicService, int> configuration,
                                                              IFluentExportStrategyConfiguration <BasicService> strategyConfiguration)
        {
            configuration.As(typeof(IBasicService));

            strategyConfiguration.Received().As(typeof(IBasicService));
        }
        public void ProxyFluentExportStrategyConfiguration_WithMetadata(FluentWithCtorConfiguration <int> configuration,
                                                                        IFluentExportStrategyConfiguration strategyConfiguration)
        {
            configuration.WithMetadata(5, 10);

            strategyConfiguration.Received().WithMetadata(5, 10);
        }
        public void ProxyFluentExportStrategyConfiguration_As_Generic([Locate] FluentWithCtorConfiguration <BasicService, int> configuration,
                                                                      IFluentExportStrategyConfiguration <BasicService> strategyConfiguration)
        {
            configuration.As <IBasicService>();

            strategyConfiguration.Received().As <IBasicService>();
        }
        public void ProxyFluentExportStrategyConfiguration_WithCtorCollectionParam([Locate] FluentWithCtorConfiguration <BasicService, int> configuration,
                                                                                   IFluentExportStrategyConfiguration <BasicService> strategyConfiguration)
        {
            configuration.WithCtorCollectionParam <IEnumerable <int>, int>();

            strategyConfiguration.Received().WithCtorCollectionParam <IEnumerable <int>, int>();
        }
        public void ProxyFluentExportStrategyConfiguration_ExternallyOwned(FluentWithCtorConfiguration <int> configuration,
                                                                           IFluentExportStrategyConfiguration strategyConfiguration)
        {
            configuration.ExternallyOwned();

            strategyConfiguration.Received().ExternallyOwned();
        }
        public void ProxyFluentExportStrategyConfiguration_WithCtorParam_Multi_5_Arg([Locate] FluentWithCtorConfiguration <BasicService, int> configuration,
                                                                                     IFluentExportStrategyConfiguration <BasicService> strategyConfiguration)
        {
            Func <IExportLocatorScope, StaticInjectionContext, IInjectionContext, IBasicService, IMultipleService, int> func = (scope, staticContext, context, basic, multiple) => 5;

            configuration.WithCtorParam(func);

            strategyConfiguration.Received().WithCtorParam(func);
        }
        public void ProxyFluentExportStrategyConfiguration_WithCtorParam_Multi_1_Arg([Locate] FluentWithCtorConfiguration <BasicService, int> configuration,
                                                                                     IFluentExportStrategyConfiguration <BasicService> strategyConfiguration)
        {
            Func <IExportLocatorScope, int> func = (scope) => 5;

            configuration.WithCtorParam(func);

            strategyConfiguration.Received().WithCtorParam(func);
        }
        public void ProxyFluentExportStrategyConfiguration_WithCtorParam([Locate] FluentWithCtorConfiguration <BasicService, int> configuration,
                                                                         IFluentExportStrategyConfiguration <BasicService> strategyConfiguration)
        {
            Func <int> func = () => 5;

            configuration.WithCtorParam(func);

            strategyConfiguration.Received().WithCtorParam(func);
        }
        public void ProxyFluentExportStrategyConfiguration_DisposalCleanup([Locate] FluentWithCtorConfiguration <BasicService, int> configuration,
                                                                           IFluentExportStrategyConfiguration <BasicService> strategyConfiguration)
        {
            Action <BasicService> func = service => service.TestMethod();

            configuration.DisposalCleanupDelegate(func);

            strategyConfiguration.Received().DisposalCleanupDelegate(func);
        }
        public void ProxyFluentExportStrategyConfiguration_ByInterfaces([Locate] FluentWithCtorConfiguration <BasicService, int> configuration,
                                                                        IFluentExportStrategyConfiguration <BasicService> strategyConfiguration)
        {
            Func <Type, bool> func = type => true;

            configuration.ByInterfaces(func);

            strategyConfiguration.Received().ByInterfaces(func);
        }
        public void ProxyFluentExportStrategyConfiguration_Apply([Locate] FluentWithCtorConfiguration <BasicService, int> configuration,
                                                                 IFluentExportStrategyConfiguration <BasicService> strategyConfiguration)
        {
            Action <BasicService> func = service => service.TestMethod();

            configuration.Apply(func);

            strategyConfiguration.Received().Apply(func);
        }
        public void ProxyFluentExportStrategyConfiguration_WithCtorParam(FluentWithCtorConfiguration <int> configuration,
                                                                         IFluentExportStrategyConfiguration strategyConfiguration)
        {
            Func <int> func = () => 5;

            configuration.WithCtorParam(func);

            strategyConfiguration.Received().WithCtorParam(func);
        }
        public void ProxyFluentExportStrategyConfiguration_UsingLifestyle(FluentWithCtorConfiguration <int> configuration,
                                                                          IFluentExportStrategyConfiguration strategyConfiguration)
        {
            ICompiledLifestyle lifestyle = new SingletonLifestyle();

            configuration.UsingLifestyle(lifestyle);

            strategyConfiguration.Lifestyle.Received().Custom(lifestyle);
        }
        public void ProxyFluentExportStrategyConfiguration_ImportMembers(FluentWithCtorConfiguration <int> configuration,
                                                                         IFluentExportStrategyConfiguration strategyConfiguration)
        {
            Func <MemberInfo, bool> memberFunc = info => true;

            configuration.ImportMembers(memberFunc);

            strategyConfiguration.Received().ImportMembers(memberFunc);
        }
        public void ProxyFluentExportStrategyConfiguration_ByInterfaces(FluentWithCtorConfiguration <int> configuration,
                                                                        IFluentExportStrategyConfiguration strategyConfiguration)
        {
            Func <Type, bool> func = t => true;

            configuration.ByInterfaces(func);

            strategyConfiguration.Received().ByInterfaces(func);
        }
        public void ProxyFluentExportStrategyConfiguration_EnrichWithDelegate([Locate] FluentWithCtorConfiguration <BasicService, int> configuration,
                                                                              IFluentExportStrategyConfiguration <BasicService> strategyConfiguration)
        {
            Func <IExportLocatorScope, StaticInjectionContext, BasicService, BasicService> enrichmentDelegate = (scope, staticonctext, context) => new BasicService();

            configuration.EnrichWithDelegate(enrichmentDelegate);

            strategyConfiguration.Received().EnrichWithDelegate(enrichmentDelegate);
        }
        public void ProxyFluentExportStrategyConfiguration_UsingLifestyle([Locate] FluentWithCtorConfiguration <BasicService, int> configuration,
                                                                          IFluentExportStrategyConfiguration <BasicService> strategyConfiguration)
        {
            var lifestyle = new SingletonLifestyle();

            configuration.UsingLifestyle(lifestyle);

            strategyConfiguration.Lifestyle.Received().Custom(lifestyle);
        }
        public void ProxyFluentExportStrategyConfiguration_ImportProperty([Locate] FluentWithCtorConfiguration <BasicService, int> configuration,
                                                                          IFluentExportStrategyConfiguration <BasicService> strategyConfiguration)
        {
            Expression <Func <BasicService, int> > func = service => service.Count;

            configuration.ImportProperty(func);

            strategyConfiguration.Received().ImportProperty(func);
        }
        public void ProxyFluentExportStrategyConfiguration_ImportMembers([Locate] FluentWithCtorConfiguration <BasicService, int> configuration,
                                                                         IFluentExportStrategyConfiguration <BasicService> strategyConfiguration)
        {
            Func <MemberInfo, bool> func = info => true;

            configuration.ImportMembers(func);

            strategyConfiguration.Received().ImportMembers(func);
        }
        public void ProxyFluentExportStrategyConfiguration_ImportMethods([Locate] FluentWithCtorConfiguration <BasicService, int> configuration,
                                                                         IFluentExportStrategyConfiguration <BasicService> strategyConfiguration)
        {
            Expression <Action <BasicService> > action = service => service.TestMethod();

            configuration.ImportMethod(action);

            strategyConfiguration.Received().ImportMethod(action);
        }
Beispiel #26
0
        private static IFluentExportStrategyConfiguration ConfigureLifetime(this IFluentExportStrategyConfiguration configuration, ServiceLifetime lifetime)
        {
            switch (lifetime)
            {
            case ServiceLifetime.Scoped:
                return(configuration.Lifestyle.SingletonPerScope());

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

            return(configuration);
        }
Beispiel #27
0
        internal static IFluentExportStrategyConfiguration ConfigureLifetime(this IFluentExportStrategyConfiguration configuration, Lifecycle lifetime)
        {
            switch (lifetime)
            {
            case Lifecycle.Scoped:
                return(configuration.Lifestyle.SingletonPerScope());

            case Lifecycle.Singleton:
                return(configuration.Lifestyle.Singleton());

            default:
                return(configuration);
            }
        }
        protected void SetLifetime(ServiceLifetime serviceLifetime, IFluentExportStrategyConfiguration registrationBuilder)
        {
            switch (serviceLifetime)
            {
            case ServiceLifetime.Scoped:
                registrationBuilder.Lifestyle.SingletonPerScope();
                break;

            case ServiceLifetime.Singleton:
                registrationBuilder.Lifestyle.Singleton();

                break;

            case ServiceLifetime.Transient:

                break;
            }
        }
Beispiel #29
0
 /// <summary>
 /// Default constructor
 /// </summary>
 /// <param name="strategy"></param>
 /// <param name="constructorParameterInfo"></param>
 public FluentWithCtorConfiguration(IFluentExportStrategyConfiguration strategy, ConstructorParameterInfo constructorParameterInfo) : base(strategy)
 {
     _constructorParameterInfo = constructorParameterInfo;
 }
        /// <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 IFluentExportStrategyConfiguration <T> IfNotRegistered <T>(this IFluentExportStrategyConfiguration <T> configuration, Type type, object key = null)
        {
            var activationStrategyProvider = configuration as IActivationStrategyProvider;

            return(configuration.OnlyIf(block => !block.IsExported(type, key, activationStrategyProvider?.GetStrategy() as ICompiledExportStrategy)));
        }
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="exportPropertyInfo">property info to export</param>
        /// <param name="strategy">export strategy</param>
        public FluentExportPropertyConfiguration(ExportPropertyInfo exportPropertyInfo,
			IFluentExportStrategyConfiguration strategy)
            : base(strategy)
        {
            this.exportPropertyInfo = exportPropertyInfo;
        }