From ba91b68c6469bef58f08a5d20518c0df176d9808 Mon Sep 17 00:00:00 2001
From: GeWuYou <95328647+GeWuYou@users.noreply.github.com>
Date: Sat, 17 Jan 2026 19:44:56 +0800
Subject: [PATCH] =?UTF-8?q?feat(architecture):=20=E4=BF=AE=E6=94=B9Install?=
=?UTF-8?q?Module=E5=92=8CRegisterLifecycleHook=E6=96=B9=E6=B3=95=E8=BF=94?=
=?UTF-8?q?=E5=9B=9E=E5=AE=9E=E4=BE=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- InstallModule方法现在返回安装的模块实例
- RegisterLifecycleHook方法现在返回注册的钩子实例
- 为两个方法添加返回值的XML文档注释
- 更新接口定义以匹配新的返回类型
---
.../architecture/IArchitecture.cs | 8 +++++---
GFramework.Core/architecture/Architecture.cs | 8 ++++++--
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/GFramework.Core.Abstractions/architecture/IArchitecture.cs b/GFramework.Core.Abstractions/architecture/IArchitecture.cs
index 332c6fc..c81f070 100644
--- a/GFramework.Core.Abstractions/architecture/IArchitecture.cs
+++ b/GFramework.Core.Abstractions/architecture/IArchitecture.cs
@@ -1,4 +1,4 @@
-using GFramework.Core.Abstractions.model;
+using GFramework.Core.Abstractions.model;
using GFramework.Core.Abstractions.system;
using GFramework.Core.Abstractions.utility;
@@ -56,11 +56,13 @@ public interface IArchitecture : IAsyncInitializable
/// 安装架构模块
///
/// 要安装的模块
- void InstallModule(IArchitectureModule module);
+ /// 安装的模块实例
+ IArchitectureModule InstallModule(IArchitectureModule module);
///
/// 注册生命周期钩子
///
/// 生命周期钩子实例
- void RegisterLifecycleHook(IArchitectureLifecycle hook);
+ /// 注册的钩子实例
+ IArchitectureLifecycle RegisterLifecycleHook(IArchitectureLifecycle hook);
}
\ No newline at end of file
diff --git a/GFramework.Core/architecture/Architecture.cs b/GFramework.Core/architecture/Architecture.cs
index a451f87..c4c038e 100644
--- a/GFramework.Core/architecture/Architecture.cs
+++ b/GFramework.Core/architecture/Architecture.cs
@@ -36,7 +36,8 @@ public abstract class Architecture(
/// 安装架构模块
///
/// 要安装的模块
- public void InstallModule(IArchitectureModule module)
+ /// 安装的模块实例
+ public IArchitectureModule InstallModule(IArchitectureModule module)
{
var name = module.GetType().Name;
var logger = LoggerFactoryResolver.Provider.CreateLogger(name);
@@ -45,6 +46,7 @@ public abstract class Architecture(
Container.RegisterPlurality(module);
module.Install(this);
logger.Info($"Module installed: {name}");
+ return module;
}
#endregion
@@ -222,12 +224,14 @@ public abstract class Architecture(
/// 注册生命周期钩子
///
/// 生命周期钩子实例
- public void RegisterLifecycleHook(IArchitectureLifecycle hook)
+ /// 注册的钩子实例
+ public IArchitectureLifecycle RegisterLifecycleHook(IArchitectureLifecycle hook)
{
if (CurrentPhase >= ArchitecturePhase.Ready && !Configuration.ArchitectureProperties.AllowLateRegistration)
throw new InvalidOperationException(
"Cannot register lifecycle hook after architecture is Ready");
_lifecycleHooks.Add(hook);
+ return hook;
}
///