public IProvider CreateProvider( Type resultType, string concreteIdentifier, string resourcePath, object identifier, string gameObjectName, string gameObjectGroupName) { _markRegistry.MarkSingleton( resultType, concreteIdentifier, SingletonTypes.ToSubContainerPrefabResource); var customSingletonId = new CustomSingletonId( concreteIdentifier, resourcePath); CreatorInfo creatorInfo; if (_subContainerCreators.TryGetValue(customSingletonId, out creatorInfo)) { Assert.IsEqual(creatorInfo.GameObjectName, gameObjectName, "Ambiguous creation parameters (gameObjectName) when using ToSubContainerPrefab with AsSingle"); Assert.IsEqual(creatorInfo.GameObjectGroupName, gameObjectGroupName, "Ambiguous creation parameters (gameObjectGroupName) when using ToSubContainerPrefab with AsSingle"); } else { var creator = new SubContainerCreatorCached( new SubContainerCreatorByPrefab( _container, new PrefabProviderResource(resourcePath), gameObjectName, gameObjectGroupName)); creatorInfo = new CreatorInfo( gameObjectName, gameObjectGroupName, creator); _subContainerCreators.Add(customSingletonId, creatorInfo); } return(new SubContainerDependencyProvider( resultType, identifier, creatorInfo.Creator)); }
public IProvider CreateProvider( Type resultType, string concreteIdentifier, Action <DiContainer> installMethod, object identifier) { _markRegistry.MarkSingleton( new SingletonId(resultType, concreteIdentifier), SingletonTypes.ToSubContainerMethod); ISubContainerCreator subContainerCreator; var subContainerSingletonId = new MethodSingletonId( concreteIdentifier, installMethod); if (!_subContainerCreators.TryGetValue(subContainerSingletonId, out subContainerCreator)) { subContainerCreator = new SubContainerCreatorCached( new SubContainerCreatorByMethod( _container, installMethod)); _subContainerCreators.Add(subContainerSingletonId, subContainerCreator); } return(new SubContainerDependencyProvider( resultType, identifier, subContainerCreator)); }
public IProvider CreateProvider( Type resultType, object concreteIdentifier, UnityEngine.Object prefab, object identifier, GameObjectCreationParameters gameObjectBindInfo) { _markRegistry.MarkSingleton( resultType, concreteIdentifier, SingletonTypes.FromSubContainerPrefab); var customSingletonId = new CustomSingletonId( concreteIdentifier, prefab); CreatorInfo creatorInfo; if (_subContainerCreators.TryGetValue(customSingletonId, out creatorInfo)) { Assert.IsEqual(creatorInfo.GameObjectCreationParameters, gameObjectBindInfo, "Ambiguous creation parameters (game object name/parent info) when using ToSubContainerPrefab with AsSingle"); } else { var creator = new SubContainerCreatorCached( new SubContainerCreatorByNewPrefab(_container, new PrefabProvider(prefab), gameObjectBindInfo)); creatorInfo = new CreatorInfo(gameObjectBindInfo, creator); _subContainerCreators.Add(customSingletonId, creatorInfo); } return(new SubContainerDependencyProvider( resultType, identifier, creatorInfo.Creator)); }
void FinalizeBindingSelf(DiContainer container) { var scope = GetScope(); switch (scope) { case ScopeTypes.Transient: { RegisterProviderPerContract( container, (_, contractType) => new SubContainerDependencyProvider( contractType, _subIdentifier, _creatorFactory(container), _resolveAll)); break; } case ScopeTypes.Singleton: { var containerCreator = new SubContainerCreatorCached(_creatorFactory(container)); RegisterProviderPerContract( container, (_, contractType) => new SubContainerDependencyProvider( contractType, _subIdentifier, containerCreator, _resolveAll)); break; } default: { throw Assert.CreateException(); } } }
void FinalizeBindingConcrete(DiContainer container, List <Type> concreteTypes) { switch (BindInfo.Scope) { case ScopeTypes.Singleton: { RegisterProvidersForAllContractsPerConcreteType( container, concreteTypes, (_, concreteType) => container.SingletonProviderCreator.CreateProviderForSubContainerPrefab( concreteType, BindInfo.ConcreteIdentifier, _gameObjectBindInfo.Name, _gameObjectBindInfo.GroupName, _prefab, _subIdentifier)); break; } case ScopeTypes.Transient: { RegisterProvidersForAllContractsPerConcreteType( container, concreteTypes, (_, concreteType) => new SubContainerDependencyProvider( concreteType, _subIdentifier, new SubContainerCreatorByPrefab( container, new PrefabProvider(_prefab), _gameObjectBindInfo.Name, _gameObjectBindInfo.GroupName))); break; } case ScopeTypes.Cached: { var containerCreator = new SubContainerCreatorCached( new SubContainerCreatorByPrefab( container, new PrefabProvider(_prefab), _gameObjectBindInfo.Name, _gameObjectBindInfo.GroupName)); RegisterProvidersForAllContractsPerConcreteType( container, concreteTypes, (_, concreteType) => new SubContainerDependencyProvider( concreteType, _subIdentifier, containerCreator)); break; } default: { throw Assert.CreateException(); } } }
void FinalizeBindingConcrete(DiContainer container, List <Type> concreteTypes) { switch (BindInfo.Scope) { case ScopeTypes.Singleton: { RegisterProvidersForAllContractsPerConcreteType( container, concreteTypes, (_, concreteType) => container.SingletonProviderCreator.CreateProviderForSubContainerMethod( concreteType, BindInfo.ConcreteIdentifier, _installMethod, _subIdentifier)); break; } case ScopeTypes.Transient: { // Note: each contract/concrete pair gets its own container here RegisterProvidersPerContractAndConcreteType( container, concreteTypes, (contractType, concreteType) => new SubContainerDependencyProvider( concreteType, _subIdentifier, new SubContainerCreatorByMethod(container, _installMethod))); break; } case ScopeTypes.Cached: { var creator = new SubContainerCreatorCached( new SubContainerCreatorByMethod(container, _installMethod)); // Note: each contract/concrete pair gets its own container RegisterProvidersForAllContractsPerConcreteType( container, concreteTypes, (_, concreteType) => new SubContainerDependencyProvider( concreteType, _subIdentifier, creator)); break; } default: { throw Assert.CreateException(); } } }
void FinalizeBindingConcrete(DiContainer container, List<Type> concreteTypes) { switch (BindInfo.Scope) { case ScopeTypes.Singleton: { RegisterProvidersForAllContractsPerConcreteType( container, concreteTypes, (_, concreteType) => container.SingletonProviderCreator.CreateProviderForSubContainerPrefab( concreteType, BindInfo.ConcreteIdentifier, _gameObjectBindInfo.Name, _gameObjectBindInfo.GroupName, _prefab, _subIdentifier)); break; } case ScopeTypes.Transient: { RegisterProvidersForAllContractsPerConcreteType( container, concreteTypes, (_, concreteType) => new SubContainerDependencyProvider( concreteType, _subIdentifier, new SubContainerCreatorByPrefab( container, new PrefabProvider(_prefab), _gameObjectBindInfo.Name, _gameObjectBindInfo.GroupName))); break; } case ScopeTypes.Cached: { var containerCreator = new SubContainerCreatorCached( new SubContainerCreatorByPrefab( container, new PrefabProvider(_prefab), _gameObjectBindInfo.Name, _gameObjectBindInfo.GroupName)); RegisterProvidersForAllContractsPerConcreteType( container, concreteTypes, (_, concreteType) => new SubContainerDependencyProvider( concreteType, _subIdentifier, containerCreator)); break; } default: { throw Assert.CreateException(); } } }
void FinalizeBindingSelf(DiContainer container) { switch (BindInfo.Scope) { case ScopeTypes.Singleton: { RegisterProviderPerContract( container, (_, contractType) => container.SingletonProviderCreator.CreateProviderForSubContainerPrefabResource( contractType, BindInfo.ConcreteIdentifier, _gameObjectBindInfo.Name, _gameObjectBindInfo.GroupName, _resourcePath, _subIdentifier)); break; } case ScopeTypes.Transient: { RegisterProviderPerContract( container, (_, contractType) => new SubContainerDependencyProvider( contractType, _subIdentifier, new SubContainerCreatorByPrefab( container, new PrefabProviderResource(_resourcePath), _gameObjectBindInfo.Name, _gameObjectBindInfo.GroupName))); break; } case ScopeTypes.Cached: { var containerCreator = new SubContainerCreatorCached( new SubContainerCreatorByPrefab( container, new PrefabProviderResource(_resourcePath), _gameObjectBindInfo.Name, _gameObjectBindInfo.GroupName)); RegisterProviderPerContract( container, (_, contractType) => new SubContainerDependencyProvider( contractType, _subIdentifier, containerCreator)); break; } default: { throw Assert.CreateException(); } } }
private void FinalizeBindingSelf(DiContainer container) { switch (GetScope()) { case ScopeTypes.Singleton: { RegisterProviderPerContract( container, (_, contractType) => container.SingletonProviderCreator.CreateProviderForSubContainerPrefab( contractType, BindInfo.ConcreteIdentifier, _gameObjectBindInfo, _prefab, _subIdentifier)); break; } case ScopeTypes.Transient: { RegisterProviderPerContract( container, (_, contractType) => new SubContainerDependencyProvider( contractType, _subIdentifier, new SubContainerCreatorByNewPrefab( container, new PrefabProvider(_prefab), _gameObjectBindInfo))); break; } case ScopeTypes.Cached: { var containerCreator = new SubContainerCreatorCached( new SubContainerCreatorByNewPrefab( container, new PrefabProvider(_prefab), _gameObjectBindInfo)); RegisterProviderPerContract( container, (_, contractType) => new SubContainerDependencyProvider( contractType, _subIdentifier, containerCreator)); break; } default: { throw Assert.CreateException(); } } }
void FinalizeBindingConcrete(DiContainer container, List<Type> concreteTypes) { switch (BindInfo.Scope) { case ScopeTypes.Singleton: { RegisterProvidersForAllContractsPerConcreteType( container, concreteTypes, (_, concreteType) => container.SingletonProviderCreator.CreateProviderForSubContainerMethod( concreteType, BindInfo.ConcreteIdentifier, _installMethod, _subIdentifier)); break; } case ScopeTypes.Transient: { // Note: each contract/concrete pair gets its own container here RegisterProvidersPerContractAndConcreteType( container, concreteTypes, (contractType, concreteType) => new SubContainerDependencyProvider( concreteType, _subIdentifier, new SubContainerCreatorByMethod(container, _installMethod))); break; } case ScopeTypes.Cached: { var creator = new SubContainerCreatorCached( new SubContainerCreatorByMethod(container, _installMethod)); // Note: each contract/concrete pair gets its own container RegisterProvidersForAllContractsPerConcreteType( container, concreteTypes, (_, concreteType) => new SubContainerDependencyProvider( concreteType, _subIdentifier, creator)); break; } default: { throw Assert.CreateException(); } } }
void FinalizeBindingSelf(DiContainer container) { switch (BindInfo.Scope) { case ScopeTypes.Singleton: { RegisterProviderPerContract( container, (_, contractType) => container.SingletonProviderCreator.CreateProviderForSubContainerMethod( contractType, BindInfo.ConcreteIdentifier, _installMethod, _subIdentifier)); break; } case ScopeTypes.Transient: { RegisterProviderPerContract( container, (_, contractType) => new SubContainerDependencyProvider( contractType, _subIdentifier, new SubContainerCreatorByMethod( container, _installMethod))); break; } case ScopeTypes.Cached: { var containerCreator = new SubContainerCreatorCached( new SubContainerCreatorByMethod(container, _installMethod)); RegisterProviderPerContract( container, (_, contractType) => new SubContainerDependencyProvider( contractType, _subIdentifier, containerCreator)); break; } default: { throw Assert.CreateException(); } } }
void FinalizeBindingConcrete(DiContainer container, List <Type> concreteTypes) { ScopeTypes scope = GetScope(); switch (scope) { case ScopeTypes.Transient: { // Note: each contract/concrete pair gets its own container here RegisterProvidersPerContractAndConcreteType( container, concreteTypes, (contractType, concreteType) => new SubContainerDependencyProvider( concreteType, _subIdentifier, new SubContainerCreatorByMethod(container, _installMethod), _resolveAll)); break; } case ScopeTypes.Singleton: { SubContainerCreatorCached creator = new SubContainerCreatorCached( new SubContainerCreatorByMethod(container, _installMethod)); // Note: each contract/concrete pair gets its own container RegisterProvidersForAllContractsPerConcreteType( container, concreteTypes, (_, concreteType) => new SubContainerDependencyProvider( concreteType, _subIdentifier, creator, _resolveAll)); break; } default: { throw Assert.CreateException(); } } }
void FinalizeBindingConcrete(DiContainer container, List <Type> concreteTypes) { ScopeTypes scope = GetScope(); switch (scope) { case ScopeTypes.Transient: { RegisterProvidersForAllContractsPerConcreteType( container, concreteTypes, (_, concreteType) => new SubContainerDependencyProvider( concreteType, _subIdentifier, _subContainerCreatorFactory(container), _resolveAll)); break; } case ScopeTypes.Singleton: { SubContainerCreatorCached containerCreator = new SubContainerCreatorCached( _subContainerCreatorFactory(container)); RegisterProvidersForAllContractsPerConcreteType( container, concreteTypes, (_, concreteType) => new SubContainerDependencyProvider( concreteType, _subIdentifier, containerCreator, _resolveAll)); break; } default: { throw Assert.CreateException(); } } }
public IProvider CreateProvider( Type resultType, object concreteIdentifier, Type installerType, object identifier) { _markRegistry.MarkSingleton( resultType, concreteIdentifier, SingletonTypes.FromSubContainerInstaller); var subContainerSingletonId = new InstallerSingletonId( concreteIdentifier, installerType); ISubContainerCreator subContainerCreator; if (!_subContainerCreators.TryGetValue(subContainerSingletonId, out subContainerCreator)) { subContainerCreator = new SubContainerCreatorCached( new SubContainerCreatorByInstaller( _container, installerType)); _subContainerCreators.Add(subContainerSingletonId, subContainerCreator); } return(new SubContainerDependencyProvider( resultType, identifier, subContainerCreator)); }