BlackLambert_unity-di-package/Runtime/Scripts/Core/Context/GameObjectContext/GameObjectContext.cs
namespace SBaier.DI
{
    public class GameObjectContext : MonoContext
    {
        private ChildDIContext _currentContext;
        private GameObjectInjector _injector;
        protected override DIContext DIContext => _currentContext;
        
        protected override void DoInit(Resolver resolver)
		{
			_injector = resolver.Resolve<GameObjectInjector>();
            _currentContext = CreateDIContext(resolver);
			InstallGameObjectContextBindings();
		}

		private ChildDIContext CreateDIContext(Resolver resolver)
		{
			Factory<ChildDIContext, Resolver> contextFactory = resolver.Resolve<Factory<ChildDIContext, Resolver>>();
			return contextFactory.Create(resolver);
		}

		private void InstallGameObjectContextBindings()
		{
            GameObjectContextInstaller installer = new GameObjectContextInstaller(_currentContext);
            installer.InstallBindings(_binder);
        }

		protected override void DoInjection()
        {
            _injector.InjectIntoHierarchy(transform, DIContext.Resolver);
        }

        protected override ContextAlreadyInitializedException CreateContextAlreadyInitializedException()
        {
            return new GameObjectContextAlreadyInitializedException(name);
        }
    }
}

