Ejemplo n.º 1
0
 public FromBinderGeneric(
     BindInfo bindInfo,
     BindFinalizerWrapper finalizerWrapper)
     : base(bindInfo, finalizerWrapper)
 {
     BindingUtil.AssertIsDerivedFromTypes(typeof(TContract), BindInfo.ContractTypes);
 }
Ejemplo n.º 2
0
 public FromBinderGeneric(
     DiContainer bindContainer,
     BindInfo bindInfo,
     BindStatement bindStatement)
     : base(bindContainer, bindInfo, bindStatement)
 {
     BindingUtil.AssertIsDerivedFromTypes(typeof(TContract), BindInfo.ContractTypes);
 }
Ejemplo n.º 3
0
        public FromBinderNonGeneric To(IEnumerable <Type> concreteTypes)
        {
            BindingUtil.AssertIsDerivedFromTypes(concreteTypes, BindInfo.ContractTypes, BindInfo.InvalidBindResponse);

            BindInfo.ToChoice = ToChoices.Concrete;
            BindInfo.ToTypes  = concreteTypes.ToList();

            return(this);
        }
Ejemplo n.º 4
0
        public FromBinderNonGeneric To(IEnumerable <Type> concreteTypes)
        {
            BindingUtil.AssertIsDerivedFromTypes(concreteTypes, BindInfo.ContractTypes);

            BindInfo.ToChoice = ToChoices.Concrete;
            BindInfo.ToTypes  = concreteTypes.ToList();

            return(new FromBinderNonGeneric(
                       BindInfo, FinalizerWrapper));
        }
Ejemplo n.º 5
0
        protected ScopeArgBinder FromMethodBase <TConcrete>(Func <InjectContext, TConcrete> method)
        {
            BindingUtil.AssertIsDerivedFromTypes(typeof(TConcrete), AllParentTypes);

            SubFinalizer = new ScopableBindingFinalizer(
                BindInfo,
                SingletonTypes.ToMethod, new SingletonImplIds.ToMethod(method),
                (container, type) => new MethodProvider <TConcrete>(method, container));

            return(this);
        }
Ejemplo n.º 6
0
        protected ScopeArgBinder FromFactoryBase <TConcrete, TFactory>()
            where TFactory : IFactory <TConcrete>
        {
            BindingUtil.AssertIsDerivedFromTypes(typeof(TConcrete), AllParentTypes);

            SubFinalizer = new ScopableBindingFinalizer(
                BindInfo,
                SingletonTypes.ToFactory, typeof(TFactory),
                (container, type) => new FactoryProvider <TConcrete, TFactory>(container, BindInfo.Arguments));

            return(new ScopeArgBinder(BindInfo));
        }
Ejemplo n.º 7
0
        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));
        }
Ejemplo n.º 8
0
        protected ScopeArgConditionCopyNonLazyBinder FromMethodMultipleBase <TConcrete>(Func <InjectContext, IEnumerable <TConcrete> > method)
        {
            BindingUtil.AssertIsDerivedFromTypes(typeof(TConcrete), AllParentTypes);

            BindInfo.RequireExplicitScope = false;
            SubFinalizer = new ScopableBindingFinalizer(
                BindInfo,
                SingletonTypes.FromMethod, new SingletonImplIds.ToMethod(method),
                (container, type) => new MethodProviderMultiple <TConcrete>(method, container));

            return(this);
        }
Ejemplo n.º 9
0
        protected ScopeBinder FromResolveGetterBase <TObj, TResult>(
            object identifier, Func <TObj, TResult> method)
        {
            BindingUtil.AssertIsDerivedFromTypes(typeof(TResult), AllParentTypes);

            SubFinalizer = new ScopableBindingFinalizer(
                BindInfo,
                SingletonTypes.ToGetter,
                new SingletonImplIds.ToGetter(identifier, method),
                (container, type) => new GetterProvider <TObj, TResult>(identifier, method, container));

            return(new ScopeBinder(BindInfo));
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
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));
        }
Ejemplo n.º 12
0
        protected ScopeArgConditionCopyNonLazyBinder FromFactoryBase <TConcrete, TFactory>()
            where TFactory : IFactory <TConcrete>
        {
            BindingUtil.AssertIsDerivedFromTypes(typeof(TConcrete), AllParentTypes);

            // This is kind of like a look up method like FromMethod so don't enforce specifying scope
            BindInfo.RequireExplicitScope = false;
            SubFinalizer = new ScopableBindingFinalizer(
                BindInfo,
                SingletonTypes.FromFactory, typeof(TFactory),
                (container, type) => new FactoryProvider <TConcrete, TFactory>(container, BindInfo.Arguments));

            return(new ScopeArgConditionCopyNonLazyBinder(BindInfo));
        }
Ejemplo n.º 13
0
        public FromBinderNonGeneric To(IEnumerable <Type> concreteTypes)
        {
            BindInfo.ToChoice = ToChoices.Concrete;
            BindInfo.ToTypes  = concreteTypes.ToList();

            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);
        }
Ejemplo n.º 14
0
 public ScopeConcreteIdArgConditionCopyNonLazyBinder FromMethodMultiple(Func <InjectContext, IEnumerable <TContract> > method)
 {
     BindingUtil.AssertIsDerivedFromTypes(typeof(TContract), AllParentTypes);
     return(FromMethodMultipleBase <TContract>(method));
 }