Skip to content

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

ClassRole
AchEngineScopeScene entry point that wraps VContainer's LifetimeScope
AchEngineInstallerAbstract class that defines service registration
IServiceBuilderService registration interface independent of VContainer
ServiceLocatorStatic 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
}

Next Steps

MIT License