I am developing a platform for a videogame, it is pure c # code and I want to use Zenject for dependency injection. The idea is that this platform can initialize its dependency injection regardless of where it is being used. I have this class on the platform:
public static class DIManager
{
private static DiContainer _container;
public static DiContainer Container {get => _container; set => _container = value; }
public static void Initialize ()
{
_container = new DiContainer ();
InstallBindings ();
}
private static void InstallBindings ()
{
_container.Install <AppInstaller> ();
}
}
which creates and initializes the container that is used in the platform, but to use it outside the platform I always have to call:
_foo = DIManager.Container.TryResolve <Foo> ();
Is this a correct way to implement the idea I want? Is this way of obtaining a platform class optimal (in terms of performance)? Any ideas or suggestions you have will be appreciated, greetings.