From 60f67249d9e1b660a0daf09580edcaa4d2d9b288 Mon Sep 17 00:00:00 2001 From: OLDLI Date: Thu, 19 Mar 2020 19:52:32 +0800 Subject: [PATCH] =?UTF-8?q?IModuleOptions=E6=8E=A5=E5=8F=A3=E6=96=B0?= =?UTF-8?q?=E5=A2=9ECopy=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Admin/Directory.Build.props | 2 +- src/Admin/Library/Infrastructure/AdminOptions.cs | 11 +++++++++++ src/Admin/WebHost/_modules/Admin/_module.json | 2 +- src/Framework/Host/Directory.Build.props | 2 +- src/Framework/Options/Directory.Build.props | 2 +- .../Options/Options.Abstraction/IModuleOptions.cs | 5 +++++ .../Options/Options.Core/ModuleOptionsEngine.cs | 6 +++--- 7 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/Admin/Directory.Build.props b/src/Admin/Directory.Build.props index 6f62a624..2ed06933 100644 --- a/src/Admin/Directory.Build.props +++ b/src/Admin/Directory.Build.props @@ -4,7 +4,7 @@ 权限管理 Oldli permission - 1.8.7 + 1.8.8 NetModular Module Admin($(Name)) - $(MSBuildProjectName) $(NoWarn);1591 Latest diff --git a/src/Admin/Library/Infrastructure/AdminOptions.cs b/src/Admin/Library/Infrastructure/AdminOptions.cs index 422f6129..0dde8865 100644 --- a/src/Admin/Library/Infrastructure/AdminOptions.cs +++ b/src/Admin/Library/Infrastructure/AdminOptions.cs @@ -30,5 +30,16 @@ public class AdminOptions : IModuleOptions /// [ModuleOptionDefinition("启动时刷新模块和权限")] public bool RefreshModuleOrPermission { get; set; } = true; + + public IModuleOptions Copy() + { + return new AdminOptions + { + AuditingEnabled = AuditingEnabled, + RefreshTokenExpires = RefreshTokenExpires, + DefaultPassword = DefaultPassword, + RefreshModuleOrPermission = RefreshModuleOrPermission + }; + } } } diff --git a/src/Admin/WebHost/_modules/Admin/_module.json b/src/Admin/WebHost/_modules/Admin/_module.json index 56ceae47..a6b18c32 100644 --- a/src/Admin/WebHost/_modules/Admin/_module.json +++ b/src/Admin/WebHost/_modules/Admin/_module.json @@ -1 +1 @@ -{"Id": "Admin","Name":"权限管理","Icon":"permission","Version":"1.8.7","Description":"权限管理模块用于身份认证以及授权等功能"} +{"Id": "Admin","Name":"权限管理","Icon":"permission","Version":"1.8.8","Description":"权限管理模块用于身份认证以及授权等功能"} diff --git a/src/Framework/Host/Directory.Build.props b/src/Framework/Host/Directory.Build.props index 0893547b..2ac08834 100644 --- a/src/Framework/Host/Directory.Build.props +++ b/src/Framework/Host/Directory.Build.props @@ -1,6 +1,6 @@  - 1.8.5 + 1.8.6 diff --git a/src/Framework/Options/Directory.Build.props b/src/Framework/Options/Directory.Build.props index 60fa93c9..e6be8271 100644 --- a/src/Framework/Options/Directory.Build.props +++ b/src/Framework/Options/Directory.Build.props @@ -1,6 +1,6 @@  - 1.8.1 + 1.8.2 diff --git a/src/Framework/Options/Options.Abstraction/IModuleOptions.cs b/src/Framework/Options/Options.Abstraction/IModuleOptions.cs index 2ff09120..e51c8e31 100644 --- a/src/Framework/Options/Options.Abstraction/IModuleOptions.cs +++ b/src/Framework/Options/Options.Abstraction/IModuleOptions.cs @@ -5,5 +5,10 @@ /// public interface IModuleOptions { + /// + /// Copy + /// + /// + IModuleOptions Copy(); } } diff --git a/src/Framework/Options/Options.Core/ModuleOptionsEngine.cs b/src/Framework/Options/Options.Core/ModuleOptionsEngine.cs index 42998609..94363965 100644 --- a/src/Framework/Options/Options.Core/ModuleOptionsEngine.cs +++ b/src/Framework/Options/Options.Core/ModuleOptionsEngine.cs @@ -92,8 +92,8 @@ public void RefreshInstance(string moduleCode, Dictionary values if (instance == null) return; - //通过序列化深拷贝保留旧实例 - var oldInstance = JsonSerializer.Deserialize(JsonSerializer.Serialize(instance), descriptor.OptionsType); + //通过Copy方法创建旧实例 + var oldInstance = instance.Copy(); var storageModels = new List(); foreach (var definition in descriptor.Definitions) @@ -121,7 +121,7 @@ public void RefreshInstance(string moduleCode, Dictionary values var method = changedEventType.GetMethod("OnChanged"); if (method != null) { - method.Invoke(changedEvent, new[] { instance, oldInstance }); + method.Invoke(changedEvent, new object[] { instance, oldInstance }); } } }