コード例 #1
0
        private static void MergeBinding(IBindingConfig bindingConfig, IBindingConfig explicitBindingConfig)
        {
            // merge constructor
            if (explicitBindingConfig.Constructor != null)
            {
                bindingConfig.Constructor = explicitBindingConfig.Constructor;
            }

            // merge factory
            if (explicitBindingConfig.FactoryExpression != null)
            {
                bindingConfig.FactoryExpression = explicitBindingConfig.FactoryExpression;
            }

            // merge lifestyle
            if (explicitBindingConfig.Lifestyle != null)
            {
                bindingConfig.Lifestyle = explicitBindingConfig.Lifestyle;
            }

            foreach (var fis in explicitBindingConfig.GetFieldInfoSetters())
            {
                bindingConfig.SetFieldInfoSetter(fis.MemberInfo, fis.MemberSetter);
            }

            foreach (var pis in explicitBindingConfig.GetPropertyInfoSetters())
            {
                bindingConfig.SetPropertyInfoSetter(pis.MemberInfo, pis.MemberSetter);
            }
        }
コード例 #2
0
        private Expression CompileResolverExpression()
        {
            if (bindingConfig.FactoryExpression != null)
            {
                var factoryExpr       = CompileFactoryExpr();
                var fieldInjectors    = bindingConfig.GetFieldInfoSetters();
                var propertyInjectors = bindingConfig.GetPropertyInfoSetters();

                if (fieldInjectors.Any() || propertyInjectors.Any())
                {
                    return(CompileFactoryExprSetters(factoryExpr, PropertiesResolver));
                }
                else
                {
                    return(factoryExpr);
                }
            }
            else
            {
                return(CompileConstructorExpr());
            }
        }