protected override void OnFinalizeBinding(DiContainer container) { var factory = new FactoryProviderWrapper <TContract>( _factoryBindInfo.ProviderFunc(container), new InjectContext(container, typeof(TContract))); var settings = new MemoryPoolSettings( _poolBindInfo.InitialSize, _poolBindInfo.MaxSize, _poolBindInfo.ExpandMethod); var transientProvider = new TransientProvider( _factoryBindInfo.FactoryType, container, _factoryBindInfo.Arguments.Concat( InjectUtil.CreateArgListExplicit(factory, settings)).ToList(), BindInfo.ContextInfo, BindInfo.ConcreteIdentifier, null); IProvider mainProvider; if (BindInfo.Scope == ScopeTypes.Unset || BindInfo.Scope == ScopeTypes.Singleton) { mainProvider = BindingUtil.CreateCachedProvider(transientProvider); } else { Assert.IsEqual(BindInfo.Scope, ScopeTypes.Transient); mainProvider = transientProvider; } RegisterProviderForAllContracts(container, mainProvider); }
protected override void OnFinalizeBinding(DiContainer container) { var provider = _factoryBindInfo.ProviderFunc(container); var transientProvider = new TransientProvider( _factoryBindInfo.FactoryType, container, _factoryBindInfo.Arguments.Concat( InjectUtil.CreateArgListExplicit( provider, new InjectContext(container, typeof(TContract)))).ToList(), BindInfo.ContextInfo, BindInfo.ConcreteIdentifier, null); IProvider mainProvider; if (BindInfo.Scope == ScopeTypes.Unset || BindInfo.Scope == ScopeTypes.Singleton) { mainProvider = BindingUtil.CreateCachedProvider(transientProvider); } else { Assert.IsEqual(BindInfo.Scope, ScopeTypes.Transient); mainProvider = transientProvider; } RegisterProviderForAllContracts(container, mainProvider); }
void FinalizeBindingSelf(DiContainer container) { var scope = GetScope(); switch (scope) { case ScopeTypes.Transient: { RegisterProviderPerContract(container, _providerFactory); break; } case ScopeTypes.Singleton: { RegisterProviderPerContract( container, (_, contractType) => BindingUtil.CreateCachedProvider( _providerFactory(container, contractType))); break; } default: { throw Assert.CreateException(); } } }
void FinalizeBindingConcrete(DiContainer container, List <Type> concreteTypes) { if (concreteTypes.Count == 0) { // This can be common when using convention based bindings return; } var scope = GetScope(); switch (scope) { case ScopeTypes.Transient: { RegisterProvidersForAllContractsPerConcreteType( container, concreteTypes, _providerFactory); break; } case ScopeTypes.Singleton: { RegisterProvidersForAllContractsPerConcreteType( container, concreteTypes, (_, concreteType) => BindingUtil.CreateCachedProvider( _providerFactory(container, concreteType))); break; } default: { throw Assert.CreateException(); } } }
void FinalizeBindingConcrete(DiContainer container, List <Type> concreteTypes) { var scope = GetScope(); switch (scope) { case ScopeTypes.Transient: { RegisterProvidersForAllContractsPerConcreteType( container, concreteTypes, (_, concreteType) => _providerFactory( concreteType, new PrefabInstantiator( container, _gameObjectBindInfo, concreteType, concreteTypes, BindInfo.Arguments, new PrefabProviderResource(_resourcePath), BindInfo.InstantiatedCallback))); break; } case ScopeTypes.Singleton: { var argumentTarget = concreteTypes.OnlyOrDefault(); if (argumentTarget == null) { Assert.That(BindInfo.Arguments.IsEmpty(), "Cannot provide arguments to prefab instantiator when using more than one concrete type"); } var prefabCreator = new PrefabInstantiatorCached( new PrefabInstantiator( container, _gameObjectBindInfo, argumentTarget, concreteTypes, BindInfo.Arguments, new PrefabProviderResource(_resourcePath), BindInfo.InstantiatedCallback)); RegisterProvidersForAllContractsPerConcreteType( container, concreteTypes, (_, concreteType) => BindingUtil.CreateCachedProvider( _providerFactory(concreteType, prefabCreator))); break; } default: { throw Assert.CreateException(); } } }
void FinalizeBindingSelf(DiContainer container) { ScopeTypes scope = GetScope(); switch (scope) { case ScopeTypes.Transient: { RegisterProviderPerContract( container, (_, contractType) => _providerFactory( contractType, new PrefabInstantiator( container, _gameObjectBindInfo, contractType, BindInfo.Arguments, new PrefabProvider(_prefab)))); break; } case ScopeTypes.Singleton: { Type argumentTarget = BindInfo.ContractTypes.OnlyOrDefault(); if (argumentTarget == null) { Assert.That(BindInfo.Arguments.IsEmpty(), "Cannot provide arguments to prefab instantiator when using more than one concrete type"); } PrefabInstantiatorCached prefabCreator = new PrefabInstantiatorCached( new PrefabInstantiator( container, _gameObjectBindInfo, argumentTarget, BindInfo.Arguments, new PrefabProvider(_prefab))); RegisterProviderPerContract( container, (_, contractType) => BindingUtil.CreateCachedProvider( _providerFactory(contractType, prefabCreator))); break; } default: { throw Assert.CreateException(); } } }
protected override void OnFinalizeBinding(DiContainer container) { IProvider provider = _factoryBindInfo.ProviderFunc(container); RegisterProviderForAllContracts( container, BindingUtil.CreateCachedProvider( new TransientProvider( _factoryBindInfo.FactoryType, container, _factoryBindInfo.Arguments.Concat( InjectUtil.CreateArgListExplicit( provider, new InjectContext(container, typeof(TContract)))).ToList(), BindInfo.ContextInfo, BindInfo.ConcreteIdentifier))); }
protected override void OnFinalizeBinding(DiContainer container) { FactoryProviderWrapper <TContract> factory = new FactoryProviderWrapper <TContract>( _factoryBindInfo.ProviderFunc(container), new InjectContext(container, typeof(TContract))); MemoryPoolSettings settings = new MemoryPoolSettings( _poolBindInfo.InitialSize, _poolBindInfo.MaxSize, _poolBindInfo.ExpandMethod); RegisterProviderForAllContracts( container, BindingUtil.CreateCachedProvider( new TransientProvider( _factoryBindInfo.FactoryType, container, _factoryBindInfo.Arguments.Concat( InjectUtil.CreateArgListExplicit(factory, settings)).ToList(), BindInfo.ContextInfo, BindInfo.ConcreteIdentifier))); }