DI System - Overview
AchEngine's DI layer does not expose VContainer directly. Instead, it provides a lightweight abstraction layer.
Optional Module
The actual DI container is enabled only when VContainer (jp.hadashikick.vcontainer) is installed. Without it, ServiceLocator can still be used through manual setup.
Core Components
| Class | Role |
|---|---|
AchEngineScope | Scene entry point that wraps VContainer's LifetimeScope |
AchEngineInstaller | Abstract class that defines service registration |
IServiceBuilder | Service registration interface independent of VContainer |
ServiceLocator | Static facade for resolving services at runtime |
Basic Workflow
ServiceLifetime
csharp
public enum ServiceLifetime
{
Singleton, // One instance per container (default)
Transient, // New instance for every request
Scoped, // One instance per scope
}