For AI agents: the complete documentation index is available at /AchEngine/zh/llms.txt, the full documentation bundle is available at /AchEngine/zh/llms-full.txt, and this page is available as Markdown at /AchEngine/zh/usage/di/index.md.
  • 简体中文
  • DI 系统 — 概览

    AchEngine 提供简单的 DI 抽象层,不直接暴露 VContainer。

    可选模块

    只有安装 jp.hadashikick.vcontainer 时才启用实际容器。未安装时仍可手动配置 ServiceLocator。

    核心组件

    类型作用
    AchEngineScope封装 VContainer LifetimeScope 的场景入口
    AchEngineInstaller定义服务注册的基类
    IServiceBuilder不依赖 VContainer 的注册接口
    ServiceLocator运行时解析服务的静态门面

    基本流程

    ServiceLifetime

    public enum ServiceLifetime
    {
        Singleton, // 每个容器一个实例
        Transient, // 每次请求创建新实例
        Scoped,    // 每个作用域一个实例
    }

    下一步