예제 #1
0
 public FromBinderGeneric(
     DiContainer bindContainer,
     BindInfo.BindInfo bindInfo,
     BindStatement bindStatement)
     : base(bindContainer, bindInfo, bindStatement)
 {
     BindingUtil.AssertIsDerivedFromTypes(typeof(TContract), BindInfo.ContractTypes);
 }
        public FromBinderNonGeneric To(IEnumerable <Type> concreteTypes)
        {
            BindingUtil.AssertIsDerivedFromTypes(
                concreteTypes, BindInfo.ContractTypes, BindInfo.InvalidBindResponse);

            BindInfo.ToChoice = ToChoices.Concrete;
            BindInfo.ToTypes.Clear();
            BindInfo.ToTypes.AddRange(concreteTypes);

            return(new FromBinderNonGeneric(
                       BindContainer, BindInfo, BindStatement));
        }
예제 #3
0
        protected ScopeConcreteIdArgConditionCopyNonLazyBinder FromMethodBase <TConcrete>(Func <InjectContext, TConcrete> method)
        {
            BindingUtil.AssertIsDerivedFromTypes(typeof(TConcrete), AllParentTypes);

            BindInfo.RequireExplicitScope = false;
            // Don't know how it's created so can't assume here that it violates AsSingle
            BindInfo.MarkAsCreationBinding = false;
            SubFinalizer = new ScopableBindingFinalizer(
                BindInfo,
                (container, type) => new MethodProvider <TConcrete>(method, container));

            return(this);
        }
예제 #4
0
        protected ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveGetterBase <TObj, TResult>(
            object identifier, Func <TObj, TResult> method, InjectSources source, bool matchMultiple)
        {
            BindingUtil.AssertIsDerivedFromTypes(typeof(TResult), AllParentTypes);

            BindInfo.RequireExplicitScope = false;
            // Don't know how it's created so can't assume here that it violates AsSingle
            BindInfo.MarkAsCreationBinding = false;
            SubFinalizer = new ScopableBindingFinalizer(
                BindInfo,
                (container, type) => new GetterProvider <TObj, TResult>(identifier, method, container, source, matchMultiple));

            return(new ScopeConcreteIdArgConditionCopyNonLazyBinder(BindInfo));
        }
        public FromBinderNonGeneric To(IEnumerable <Type> concreteTypes)
        {
            BindInfo.ToChoice = ToChoices.Concrete;
            BindInfo.ToTypes.Clear();
            BindInfo.ToTypes.AddRange(concreteTypes);

            if (BindInfo.ToTypes.Count > 1 && BindInfo.ContractTypes.Count > 1)
            {
                // Be more lenient in this case to behave similar to convention based bindings
                BindInfo.InvalidBindResponse = InvalidBindResponses.Skip;
            }
            else
            {
                BindingUtil.AssertIsDerivedFromTypes(concreteTypes, BindInfo.ContractTypes, BindInfo.InvalidBindResponse);
            }

            return(this);
        }
예제 #6
0
 public ScopeConcreteIdArgConditionCopyNonLazyBinder FromMethodMultiple <TConcrete>(Func <InjectContext, IEnumerable <TConcrete> > method)
 {
     BindingUtil.AssertIsDerivedFromTypes(typeof(TConcrete), AllParentTypes);
     return(FromMethodMultipleBase <TConcrete>(method));
 }