Skip to content

Commit

Permalink
IModuleOptions接口新增Copy方法
Browse files Browse the repository at this point in the history
  • Loading branch information
iamoldli committed Mar 19, 2020
1 parent a7956fb commit 60f6724
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Admin/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Name>权限管理</Name>
<Authors>Oldli</Authors>
<Icon>permission</Icon>
<Version>1.8.7</Version>
<Version>1.8.8</Version>
<Description>NetModular Module Admin($(Name)) - $(MSBuildProjectName)</Description>
<NoWarn>$(NoWarn);1591</NoWarn>
<LangVersion>Latest</LangVersion>
Expand Down
11 changes: 11 additions & 0 deletions src/Admin/Library/Infrastructure/AdminOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,16 @@ public class AdminOptions : IModuleOptions
/// </summary>
[ModuleOptionDefinition("启动时刷新模块和权限")]
public bool RefreshModuleOrPermission { get; set; } = true;

public IModuleOptions Copy()
{
return new AdminOptions
{
AuditingEnabled = AuditingEnabled,
RefreshTokenExpires = RefreshTokenExpires,
DefaultPassword = DefaultPassword,
RefreshModuleOrPermission = RefreshModuleOrPermission
};
}
}
}
2 changes: 1 addition & 1 deletion src/Admin/WebHost/_modules/Admin/_module.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Id": "Admin","Name":"权限管理","Icon":"permission","Version":"1.8.7","Description":"权限管理模块用于身份认证以及授权等功能"}
{"Id": "Admin","Name":"权限管理","Icon":"permission","Version":"1.8.8","Description":"权限管理模块用于身份认证以及授权等功能"}
2 changes: 1 addition & 1 deletion src/Framework/Host/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>1.8.5</Version>
<Version>1.8.6</Version>
</PropertyGroup>

<Import Project="..\Directory.Build.props" />
Expand Down
2 changes: 1 addition & 1 deletion src/Framework/Options/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>1.8.1</Version>
<Version>1.8.2</Version>
</PropertyGroup>

<Import Project="..\Directory.Build.props" />
Expand Down
5 changes: 5 additions & 0 deletions src/Framework/Options/Options.Abstraction/IModuleOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@
/// </summary>
public interface IModuleOptions
{
/// <summary>
/// Copy
/// </summary>
/// <returns></returns>
IModuleOptions Copy();
}
}
6 changes: 3 additions & 3 deletions src/Framework/Options/Options.Core/ModuleOptionsEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ public void RefreshInstance(string moduleCode, Dictionary<string, object> values
if (instance == null)
return;

//通过序列化深拷贝保留旧实例
var oldInstance = JsonSerializer.Deserialize(JsonSerializer.Serialize(instance), descriptor.OptionsType);
//通过Copy方法创建旧实例
var oldInstance = instance.Copy();

var storageModels = new List<ModuleOptionStorageModel>();
foreach (var definition in descriptor.Definitions)
Expand Down Expand Up @@ -121,7 +121,7 @@ public void RefreshInstance(string moduleCode, Dictionary<string, object> values
var method = changedEventType.GetMethod("OnChanged");
if (method != null)
{
method.Invoke(changedEvent, new[] { instance, oldInstance });
method.Invoke(changedEvent, new object[] { instance, oldInstance });
}
}
}
Expand Down

0 comments on commit 60f6724

Please sign in to comment.