mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-25 21:34:28 +08:00
feat(architecture): 修改InstallModule和RegisterLifecycleHook方法返回实例
- InstallModule方法现在返回安装的模块实例 - RegisterLifecycleHook方法现在返回注册的钩子实例 - 为两个方法添加返回值的XML文档注释 - 更新接口定义以匹配新的返回类型
This commit is contained in:
parent
3bc7e84af4
commit
ba91b68c64
@ -1,4 +1,4 @@
|
|||||||
using GFramework.Core.Abstractions.model;
|
using GFramework.Core.Abstractions.model;
|
||||||
using GFramework.Core.Abstractions.system;
|
using GFramework.Core.Abstractions.system;
|
||||||
using GFramework.Core.Abstractions.utility;
|
using GFramework.Core.Abstractions.utility;
|
||||||
|
|
||||||
@ -56,11 +56,13 @@ public interface IArchitecture : IAsyncInitializable
|
|||||||
/// 安装架构模块
|
/// 安装架构模块
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="module">要安装的模块</param>
|
/// <param name="module">要安装的模块</param>
|
||||||
void InstallModule(IArchitectureModule module);
|
/// <returns>安装的模块实例</returns>
|
||||||
|
IArchitectureModule InstallModule(IArchitectureModule module);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 注册生命周期钩子
|
/// 注册生命周期钩子
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hook">生命周期钩子实例</param>
|
/// <param name="hook">生命周期钩子实例</param>
|
||||||
void RegisterLifecycleHook(IArchitectureLifecycle hook);
|
/// <returns>注册的钩子实例</returns>
|
||||||
|
IArchitectureLifecycle RegisterLifecycleHook(IArchitectureLifecycle hook);
|
||||||
}
|
}
|
||||||
@ -36,7 +36,8 @@ public abstract class Architecture(
|
|||||||
/// 安装架构模块
|
/// 安装架构模块
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="module">要安装的模块</param>
|
/// <param name="module">要安装的模块</param>
|
||||||
public void InstallModule(IArchitectureModule module)
|
/// <returns>安装的模块实例</returns>
|
||||||
|
public IArchitectureModule InstallModule(IArchitectureModule module)
|
||||||
{
|
{
|
||||||
var name = module.GetType().Name;
|
var name = module.GetType().Name;
|
||||||
var logger = LoggerFactoryResolver.Provider.CreateLogger(name);
|
var logger = LoggerFactoryResolver.Provider.CreateLogger(name);
|
||||||
@ -45,6 +46,7 @@ public abstract class Architecture(
|
|||||||
Container.RegisterPlurality(module);
|
Container.RegisterPlurality(module);
|
||||||
module.Install(this);
|
module.Install(this);
|
||||||
logger.Info($"Module installed: {name}");
|
logger.Info($"Module installed: {name}");
|
||||||
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -222,12 +224,14 @@ public abstract class Architecture(
|
|||||||
/// 注册生命周期钩子
|
/// 注册生命周期钩子
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hook">生命周期钩子实例</param>
|
/// <param name="hook">生命周期钩子实例</param>
|
||||||
public void RegisterLifecycleHook(IArchitectureLifecycle hook)
|
/// <returns>注册的钩子实例</returns>
|
||||||
|
public IArchitectureLifecycle RegisterLifecycleHook(IArchitectureLifecycle hook)
|
||||||
{
|
{
|
||||||
if (CurrentPhase >= ArchitecturePhase.Ready && !Configuration.ArchitectureProperties.AllowLateRegistration)
|
if (CurrentPhase >= ArchitecturePhase.Ready && !Configuration.ArchitectureProperties.AllowLateRegistration)
|
||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
"Cannot register lifecycle hook after architecture is Ready");
|
"Cannot register lifecycle hook after architecture is Ready");
|
||||||
_lifecycleHooks.Add(hook);
|
_lifecycleHooks.Add(hook);
|
||||||
|
return hook;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user