-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #900 from simple-robot/support-config-base-seriali…
…zeModule ApplicationBuilder中新增可配置项 `serializersModule` 以允许配置一个自定义的序列化模块'基底'
- Loading branch information
Showing
13 changed files
with
235 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* Project https://github.com/simple-robot/simpler-robot | ||
* Email [email protected] | ||
* | ||
* This file is part of the Simple Robot Library. | ||
* This file is part of the Simple Robot Library (Alias: simple-robot, simbot, etc.). | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
|
@@ -24,7 +24,11 @@ | |
package love.forte.simbot.application | ||
|
||
import kotlinx.coroutines.Job | ||
import kotlinx.serialization.modules.EmptySerializersModule | ||
import kotlinx.serialization.modules.SerializersModule | ||
import love.forte.simbot.common.coroutines.linkTo | ||
import love.forte.simbot.component.Components | ||
import love.forte.simbot.plugin.Plugins | ||
import kotlin.coroutines.CoroutineContext | ||
import kotlin.coroutines.EmptyCoroutineContext | ||
|
||
|
@@ -51,6 +55,13 @@ public interface ApplicationConfiguration { | |
*/ | ||
public val coroutineContext: CoroutineContext | ||
|
||
/** | ||
* [ApplicationBuilder.serializersModule] 所配置的**基础**序列化模块信息。 | ||
* 不包含 [Components] 中的所有其他组件合并后的结果。 | ||
* | ||
* @since 4.5.0 | ||
*/ | ||
public val serializersModule: SerializersModule | ||
} | ||
|
||
/** | ||
|
@@ -67,6 +78,20 @@ public interface ApplicationBuilder { | |
* @see ApplicationConfiguration.coroutineContext | ||
*/ | ||
public var coroutineContext: CoroutineContext | ||
|
||
/** | ||
* 一个用于 [Components.serializersModule] 的基础序列化模块, | ||
* [Components] 中所有组件的 [SerializersModule] 聚合完成后, | ||
* 会以此 [serializersModule] 为基准构建 [Components.serializersModule]。 | ||
* | ||
* ```kotlin | ||
* val finalModule = | ||
* parentSerializersModule overwriteWith allComponentsSerializersModule | ||
* ``` | ||
* | ||
* @since 4.5.0 | ||
*/ | ||
public var serializersModule: SerializersModule | ||
} | ||
|
||
/** | ||
|
@@ -75,4 +100,5 @@ public interface ApplicationBuilder { | |
*/ | ||
public abstract class AbstractApplicationBuilder : ApplicationBuilder { | ||
override var coroutineContext: CoroutineContext = EmptyCoroutineContext | ||
override var serializersModule: SerializersModule = EmptySerializersModule() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* Project https://github.com/simple-robot/simpler-robot | ||
* Email [email protected] | ||
* | ||
* This file is part of the Simple Robot Library. | ||
* This file is part of the Simple Robot Library (Alias: simple-robot, simbot, etc.). | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
|
@@ -65,6 +65,7 @@ class ComponentTests { | |
private val testContext = object : ComponentConfigureContext { | ||
override val applicationConfiguration: ApplicationConfiguration = object : ApplicationConfiguration { | ||
override val coroutineContext: CoroutineContext = EmptyCoroutineContext | ||
override val serializersModule: SerializersModule = EmptySerializersModule() | ||
} | ||
|
||
override val applicationEventRegistrar: ApplicationEventRegistrar = object : ApplicationEventRegistrar { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.