> For the complete documentation index, see [llms.txt](https://docs.axuslab.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.axuslab.com/1.-common-structures/module_system.md).

# 모듈 시스템 - Module System

Module System

#### 설명

"모듈 빌드란 프로그래밍에서 모듈을 생성하고 구성하는 과정을 가리킵니다. 모듈은 프로그램을 여러 부분으로 나누어 관리하고 유지보수하기 쉽게 만드는 데 도움이 되는 기술입니다."

Axs는 모듈을 빌드하고 응용 프로그램을 만들기 위해 구성하는 인프라를 제공합니다. 모듈은 다른 모듈에 종속될 수 있습니다. 이것에 대한 종속성을 해결할 수 있는 방법도 같이 제공하고 있습니다.

![모듈 시스템](/files/YwgLn6NP0UWIb7eOESGw)

#### 모듈 정의

가장 간단하게 아래와 같이 모듈을 정의할 수 있습니다. 이 모듈에서 해당하는 어셈블리에서 요구하는 전처리나, 객체 초기화를 진행할 수 있습니다. 모듈에서 종속성 주입을 위한 객처 등록과 애플리케이션에 새 기능을 추가하는 작업을 할 수 있습니다.

```csharp
public class SampleApplicationModule : AxsModule
{
    public override void Initialize()
    {
        IocManager.RegisterAssembly(Assembly.GetExecutingAssembly());
    }
}
```

#### 모듈간 종속성

아래와 같이 DependsOn 어트리뷰트를 사용하여 종속성을 명시적으로 선언 해야 합니다. SampleCoreModule가 실행 후 SampleApplicationModule가 실행이 된다.

![모듈간 의존성](/files/OHUc82YQ73Gu3NBbGoiV)

```csharp
[DependsOn(typeof(SampleCoreModule))]
public class SampleApplicationModule : AxsModule
{
    public override void Initialize()
    {
        IocManager.RegisterAssembly(Assembly.GetExecutingAssembly());
    }
}
```

#### 예제

```csharp
public class MySampleModule1 : AxsModule
{
    public override void Initialize()
    {
        IocManager.RegisterAssembly(Assembly.GetExecutingAssembly());
    }

    public void MySampleModuleMethod1()
    {
        //this is a custom method of this module
    }
}

[DependsOn(typeof(MySampleModule1))]
public class MySampleModule2 : AxsModule
{
    private readonly MySampleModule1 _myModule1;

    public MyModule2(MySampleModule1 mySampleModule1)
    {
        _mySampleModule1 = mySampleModule1;
    }

    public override void PreInitialize()
    {
        _mySampleModule1.MySampleModuleMethod1(); //MySampleModule1's 메서드를 호출한다.
    }

    public override void Initialize()
    {
        IocManager.RegisterAssembly(Assembly.GetExecutingAssembly());
    }
}
```

![샘플 어플리케이션 모듈의 의존성](/files/Fq9Dx4yIVOqHI1XAt24H)

#### 확인

아래와 같이 각 모듈에서 브레이크 포인트를 걸어서 프로그램이 시작을 할 때 단계별로 실행이 되는것을 확인할 수 있습니다.

![picture 1](/files/GlsbpqFAd5JdIWMv4Egr)

이 부분에서 각 단계에 맞게 초기화 및 세팅을 진행하면 됩니다.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.axuslab.com/1.-common-structures/module_system.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
