From 82f899c75f875dbcb64efdc3326e27c5a114dbb8 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Tue, 11 May 2021 09:58:15 +0800 Subject: [PATCH] provides extensions for overwriting RulesEngine --- aspnet-core/LINGYUN.MicroService.Common.sln | 2 +- .../RulesEngine/RulesEngineContributor.cs | 20 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/aspnet-core/LINGYUN.MicroService.Common.sln b/aspnet-core/LINGYUN.MicroService.Common.sln index 13e67fa2f..3b38a85c6 100644 --- a/aspnet-core/LINGYUN.MicroService.Common.sln +++ b/aspnet-core/LINGYUN.MicroService.Common.sln @@ -152,7 +152,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Rules.RulesEngi EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Rules.RulesEngine.Tests", "tests\LINGYUN.Abp.Rules.RulesEngine.Tests\LINGYUN.Abp.Rules.RulesEngine.Tests.csproj", "{CF253F0A-3A45-40EE-875F-0E57C8968C48}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Rules.NRules.Tests", "tests\LINGYUN.Abp.Rules.NRules.Tests\LINGYUN.Abp.Rules.NRules.Tests.csproj", "{EF03A0A7-A93E-4DEF-A33E-F5A82E995FBF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.Abp.Rules.NRules.Tests", "tests\LINGYUN.Abp.Rules.NRules.Tests\LINGYUN.Abp.Rules.NRules.Tests.csproj", "{EF03A0A7-A93E-4DEF-A33E-F5A82E995FBF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/RulesEngineContributor.cs b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/RulesEngineContributor.cs index 8ca8c28f4..72534d926 100644 --- a/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/RulesEngineContributor.cs +++ b/aspnet-core/modules/rules/LINGYUN.Abp.Rules.RulesEngine/LINGYUN/Abp/Rules/RulesEngine/RulesEngineContributor.cs @@ -31,12 +31,7 @@ namespace LINGYUN.Abp.Rules.RulesEngine public override void Initialize(RulesInitializationContext context) { - var reSetting = new ReSettings - { - NestedRuleExecutionMode = NestedRuleExecutionMode.Performance - }; - - _ruleEngine = new Engine(Logger, reSetting); + _ruleEngine = CreateRulesEngine(); foreach (var contributor in _workflowRulesContributors) { @@ -66,6 +61,19 @@ namespace LINGYUN.Abp.Rules.RulesEngine contributor.Shutdown(); } } + /// + /// 重写自行构建规则引擎 + /// + /// + protected virtual Engine CreateRulesEngine() + { + var reSetting = new ReSettings + { + NestedRuleExecutionMode = NestedRuleExecutionMode.Performance + }; + + return new Engine(Logger, reSetting); + } protected virtual async Task ExecuteRulesAsync(T input, WorkflowRules[] workflowRules, object[] @params = null) {