# 接口定义

### DI使用接口

在DI中可以通过以下接口方法使用配置管理器

```
type DI interface {
// ...

	// UseValueStore 设置配置项管理器
	UseValueStore(v ValueStore) DI
	
	// Property 获取配置项管理器
	Property() ValueStore

	// SetDefaultProperty 设置默认配置项
	SetDefaultProperty(key string, value interface{}) DI

	// SetDefaultPropertyMap 设置多个默认配置项
	SetDefaultPropertyMap(properties map[string]interface{}) DI

	// SetProperty 设置配置项
	SetProperty(key string, value interface{}) DI

	// SetPropertyMap 设置多个配置项
	SetPropertyMap(properties map[string]interface{}) DI
}
```

### 配置管理器定义

实现以下接口的结构体，可被设置为DI的配置项管理器

```
type ValueStore interface {
	// SetDefault 设置默认配置
	SetDefault(key string, value interface{})

	// Set 设置配置
	Set(key string, value interface{})

	// Get 获取配置
	Get(key string) (val interface{})

	// GetAll 获取所有配置
	GetAll() map[string]interface{}
}
```


---

# Agent Instructions: 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://cheivin.gitbook.io/di/valuestore/definition.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.
