using System; using System.Collections.Generic; using ModestTree; using System.Linq; #if !NOT_UNITY3D using UnityEngine; #endif namespace Zenject { [NoReflectionBaking] public class FromBinderGeneric : FromBinder { public FromBinderGeneric( DiContainer bindContainer, BindInfo bindInfo, BindStatement bindStatement) : base(bindContainer, bindInfo, bindStatement) { BindingUtil.AssertIsDerivedFromTypes(typeof(TContract), BindInfo.ContractTypes); } // Shortcut for FromIFactory and also for backwards compatibility public ScopeConcreteIdArgConditionCopyNonLazyBinder FromFactory() where TFactory : IFactory { return FromIFactory(x => x.To().AsCached()); } public ScopeConcreteIdArgConditionCopyNonLazyBinder FromIFactory( Action>> factoryBindGenerator) { return FromIFactoryBase(factoryBindGenerator); } public ScopeConcreteIdArgConditionCopyNonLazyBinder FromMethod(Func method) { return FromMethodBase(ctx => method()); } public ScopeConcreteIdArgConditionCopyNonLazyBinder FromMethod(Func method) { return FromMethodBase(method); } public ScopeConcreteIdArgConditionCopyNonLazyBinder FromMethodMultiple(Func> method) { BindingUtil.AssertIsDerivedFromTypes(typeof(TContract), AllParentTypes); return FromMethodMultipleBase(method); } public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveGetter(Func method) { return FromResolveGetter(null, method); } public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveGetter(object identifier, Func method) { return FromResolveGetter(identifier, method, InjectSources.Any); } public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveGetter(object identifier, Func method, InjectSources source) { return FromResolveGetterBase(identifier, method, source, false); } public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveAllGetter(Func method) { return FromResolveAllGetter(null, method); } public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveAllGetter(object identifier, Func method) { return FromResolveAllGetter(identifier, method, InjectSources.Any); } public ScopeConcreteIdArgConditionCopyNonLazyBinder FromResolveAllGetter(object identifier, Func method, InjectSources source) { return FromResolveGetterBase(identifier, method, source, true); } public ScopeConcreteIdArgConditionCopyNonLazyBinder FromInstance(TContract instance) { return FromInstanceBase(instance); } #if !NOT_UNITY3D public ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentsInChildren( Func predicate, bool includeInactive = true) { return FromComponentsInChildren(false, predicate, includeInactive); } public ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentsInChildren( bool excludeSelf = false, Func predicate = null, bool includeInactive = true) { Func subPredicate; if (predicate != null) { subPredicate = component => predicate((TContract)(object)component); } else { subPredicate = null; } return FromComponentsInChildrenBase( excludeSelf, subPredicate, includeInactive); } public ScopeConcreteIdArgConditionCopyNonLazyBinder FromComponentsInHierarchy( Func predicate = null, bool includeInactive = true) { Func subPredicate; if (predicate != null) { subPredicate = component => predicate((TContract)(object)component); } else { subPredicate = null; } return FromComponentsInHierarchyBase(subPredicate, includeInactive); } #endif } }