-
Notifications
You must be signed in to change notification settings - Fork 299
Description
Describe the bug
I try to create a pool that gets param and value because I need this param in my custom factory for the correct initializing of instantiated objects.
The version without the param works as expected - (I mean MemoryPool, and related to it factories)
Unfortunately, the version with param cause to the exception that not clear to me why it's trying to resolve IFactory instead of the requested one - IFactory<IAtata, IKokoko>
When :
Container.Instantiate<MemoryPool<IAtata, IKokoko>>(new object[] { settings, factory });
the line is running, I get an error :
ZenjectException: Unable to resolve 'IFactory' while building object with type 'MemoryPool<IAtata, IKokoko>'. Object graph: MemoryPool<IAtata, IKokoko>
To Reproduce
Run an attached code in editor.
Expected behavior
That it will inject all as expected.
Extenject and Unity info (please complete the following information):
- Zenject version: 9.2.0
- Unity version: 2022.2.14
- Project's scripting backend [e.g. Mono/IL2CPP] : IL2CPP
Additional context
public interface IAtata
{
string Name { get; set; }
}
public interface IKokoko
{
string Name { get; set; }
}
public class Kokoko : IKokoko
{
public string Name { get; set; }
public class Factory : PlaceholderFactory<IAtata, IKokoko>
{
}
}
public class KokokoFactory : IFactory<IAtata, IKokoko>
{
public IKokoko Create(IAtata atata)
{
IKokoko kokoko = new Kokoko();
kokoko.Name = atata.Name;
return kokoko;
}
}
public class Installer : MonoInstaller<Installer>
{
public override void InstallBindings()
{
var settings = new MemoryPoolSettings()
{
InitialSize = 100,
ExpandMethod = PoolExpandMethods.Double,
};
Container.BindFactory<IAtata, IKokoko, Kokoko.Factory>().FromFactory<KokokoFactory>().NonLazy();
var factory = Container.Resolve<Kokoko.Factory>();
// ZenjectException: Unable to resolve 'IFactory<IKokoko>' while building object with type 'MemoryPool<IAtata, IKokoko>'. Object graph: MemoryPool<IAtata, IKokoko>
var pool = Container.Instantiate<MemoryPool<IAtata, IKokoko>>(new object[] { settings, factory });
}
}
