diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 1c09e8d..07c3ecc 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -71,6 +71,8 @@ export default defineConfig({ items: [ { text: '概览', link: '/zh-CN/core/' }, { text: '架构组件', link: '/zh-CN/core/architecture' }, + { text: 'Context 上下文', link: '/zh-CN/core/context' }, + { text: '异步初始化', link: '/zh-CN/core/async-initialization' }, { text: '命令系统', link: '/zh-CN/core/command' }, { text: '查询系统', link: '/zh-CN/core/query' }, { text: '事件系统', link: '/zh-CN/core/events' }, diff --git a/docs/zh-CN/api-reference/index.md b/docs/zh-CN/api-reference/index.md index 283b5fc..d3a9748 100644 --- a/docs/zh-CN/api-reference/index.md +++ b/docs/zh-CN/api-reference/index.md @@ -197,7 +197,7 @@ public abstract class AbstractCommand : IBelongToArchitecture } ``` -### AbstractQuery +### AbstractQuery`` ```csharp public abstract class AbstractQuery : IBelongToArchitecture @@ -222,7 +222,7 @@ public abstract class AbstractQuery : IBelongToArchitecture } ``` -### BindableProperty +### BindableProperty`` ```csharp public class BindableProperty diff --git a/docs/zh-CN/core/events.md b/docs/zh-CN/core/events.md index d819254..328bd4d 100644 --- a/docs/zh-CN/core/events.md +++ b/docs/zh-CN/core/events.md @@ -587,7 +587,7 @@ Components (组件) - [`architecture`](./architecture.md) - 提供全局事件系统 - [`extensions`](./extensions.md) - 提供事件扩展方法 - [`property`](./property.md) - 可绑定属性基于事件实现 -- [`controller`](./controller.md) - 控制器监听事件 +- **Controller** - 控制器监听事件(接口定义在 Core.Abstractions 中) - [`model`](./model.md) - 模型发送事件 - [`system`](./system.md) - 系统发送和监听事件 - [`command`](./command.md) - 与事件配合实现 CQRS diff --git a/docs/zh-CN/core/query.md b/docs/zh-CN/core/query.md index 435c379..329e237 100644 --- a/docs/zh-CN/core/query.md +++ b/docs/zh-CN/core/query.md @@ -478,7 +478,6 @@ public class PlayerModel : AbstractModel } } ``` -``` ### 2. 批量查询 @@ -526,6 +525,6 @@ public class GetMultipleItemCountsQuery : AbstractQuery> - [`command`](./command.md) - CQRS 的命令部分 - [`model`](./model.md) - Query 主要从 Model 获取数据 - [`system`](./system.md) - System 中可以发送 Query -- [`controller`](./controller.md) - Controller 中可以发送 Query +- **Controller** - Controller 中可以发送 Query(接口定义在 Core.Abstractions 中) - [`extensions`](./extensions.md) - 提供 SendQuery 扩展方法 - [`architecture`](./architecture.md) - 架构核心,负责查询的分发和执行 \ No newline at end of file diff --git a/docs/zh-CN/core/rule.md b/docs/zh-CN/core/rule.md index 6eaf3ac..f5a2df2 100644 --- a/docs/zh-CN/core/rule.md +++ b/docs/zh-CN/core/rule.md @@ -209,15 +209,21 @@ public interface IContextAware } // 框架负责"提供什么" -public static class CanSendExtensions +/// +/// 发送一个事件 +/// +/// 命令执行结果类型 +/// 实现 IContextAware 接口的对象 +/// 要发送的命令 +/// 命令执行结果 +/// 当 contextAware 或 command 为 null 时抛出 +public static TResult SendCommand(this IContextAware contextAware, ICommand command) { - public static void SendCommand(this ICanSendCommand self, T command) - where T : ICommand - { - // 自动注入架构上下文依赖 - command.SetContext(self.GetContext()); - command.Execute(); - } + ArgumentNullException.ThrowIfNull(contextAware); + ArgumentNullException.ThrowIfNull(command); + + var context = contextAware.GetContext(); + return context.SendCommand(command); } ``` @@ -310,7 +316,7 @@ public class DatabaseCommand : AbstractCommand, ICanAccessDatabase - [`architecture`](./architecture.md) - 定义 IArchitectureContext 接口 - [`command`](./command.md) - Command 继承 AbstractCommand (IContextAware) - [`query`](./query.md) - Query 继承 AbstractQuery (IContextAware) -- [`controller`](./controller.md) - Controller 实现 ICanSendCommand 等接口 +- **Controller** - Controller 实现 ICanSendCommand 等接口(接口定义在 Core.Abstractions 中) - [`system`](./system.md) - System 继承 AbstractSystem (IContextAware) - [`model`](./model.md) - Model 继承 AbstractModel (IContextAware) - [`extensions`](./extensions.md) - 基于规则接口提供扩展方法 \ No newline at end of file diff --git a/docs/zh-CN/troubleshooting.md b/docs/zh-CN/troubleshooting.md index 64d106c..1f5d16f 100644 --- a/docs/zh-CN/troubleshooting.md +++ b/docs/zh-CN/troubleshooting.md @@ -292,10 +292,10 @@ public void Update() 如果问题仍未解决: -1. 查看 [常见问题](../faq.md) -2. 查看 [API 参考](../api-reference/index.md) +1. 查看 [Core 文档](/zh-CN/core/) 了解更多细节 +2. 查看 [架构组件](/zh-CN/core/architecture) 了解架构设计 3. 在 [GitHub Issues](https://github.com/GeWuYou/GFramework/issues) 提交问题 -4. 查看 [教程](../tutorials/index.md) 中的示例代码 +4. 查看 [教程](/zh-CN/tutorials/) 中的示例代码 ---