From 2a112c12187170e305cb1d9cc852abbebd5cc1e3 Mon Sep 17 00:00:00 2001 From: feijie Date: Tue, 10 Dec 2024 22:55:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(docs):=20=E6=B7=BB=E5=8A=A0=E8=A7=84?= =?UTF-8?q?=E5=88=99=E5=BC=95=E6=93=8E=E6=A8=A1=E5=9D=97=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LINGYUN.Abp.Rules.NRules/README.EN.md | 70 +++++++++++++++++++ .../rules/LINGYUN.Abp.Rules.NRules/README.md | 70 +++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 aspnet-core/framework/rules/LINGYUN.Abp.Rules.NRules/README.EN.md create mode 100644 aspnet-core/framework/rules/LINGYUN.Abp.Rules.NRules/README.md diff --git a/aspnet-core/framework/rules/LINGYUN.Abp.Rules.NRules/README.EN.md b/aspnet-core/framework/rules/LINGYUN.Abp.Rules.NRules/README.EN.md new file mode 100644 index 000000000..3ad4ed0de --- /dev/null +++ b/aspnet-core/framework/rules/LINGYUN.Abp.Rules.NRules/README.EN.md @@ -0,0 +1,70 @@ +# LINGYUN.Abp.Rules.NRules + +## Module Description + +Rule engine implementation module based on [NRules](https://github.com/NRules/NRules). + +### Base Modules + +* LINGYUN.Abp.Rules + +### Features + +* Provides rule engine implementation based on NRules +* Supports automatic rule registration through dependency injection +* Supports dynamic rule loading and execution + +### Configuration + +* AbpNRulesOptions + * DefinitionRules - List of defined rules, used to store all rule types registered through dependency injection + +### How to Use + +1. Add `AbpNRulesModule` dependency + +```csharp +[DependsOn(typeof(AbpNRulesModule))] +public class YouProjectModule : AbpModule +{ +} +``` + +2. Create a rule class + +```csharp +public class YourRule : RuleBase +{ + public override void Define() + { + // Define rule conditions and actions + When() + .Match(x => x.SomeCondition); + Then() + .Do(ctx => /* Execute rule action */); + } +} +``` + +3. Register and execute rules + +```csharp +public class YourService +{ + private readonly IRuleProvider _ruleProvider; + + public YourService(IRuleProvider ruleProvider) + { + _ruleProvider = ruleProvider; + } + + public async Task ProcessAsync() + { + var input = new YourInput(); + // Execute rule validation + await _ruleProvider.ExecuteAsync(input); + } +} +``` + +[Back to TOC](../../../README.md) diff --git a/aspnet-core/framework/rules/LINGYUN.Abp.Rules.NRules/README.md b/aspnet-core/framework/rules/LINGYUN.Abp.Rules.NRules/README.md new file mode 100644 index 000000000..4999f8d01 --- /dev/null +++ b/aspnet-core/framework/rules/LINGYUN.Abp.Rules.NRules/README.md @@ -0,0 +1,70 @@ +# LINGYUN.Abp.Rules.NRules + +## 模块说明 + +基于 [NRules](https://github.com/NRules/NRules) 的规则引擎实现模块。 + +### 基础模块 + +* LINGYUN.Abp.Rules + +### 功能定义 + +* 提供基于 NRules 的规则引擎实现 +* 支持通过依赖注入自动注册规则 +* 支持规则的动态加载和执行 + +### 配置定义 + +* AbpNRulesOptions + * DefinitionRules - 定义规则列表,用于存储所有通过依赖注入注册的规则类型 + +### 如何使用 + +1. 添加 `AbpNRulesModule` 依赖 + +```csharp +[DependsOn(typeof(AbpNRulesModule))] +public class YouProjectModule : AbpModule +{ +} +``` + +2. 创建规则类 + +```csharp +public class YourRule : RuleBase +{ + public override void Define() + { + // 定义规则条件和动作 + When() + .Match(x => x.SomeCondition); + Then() + .Do(ctx => /* 执行规则动作 */); + } +} +``` + +3. 注册规则并执行 + +```csharp +public class YourService +{ + private readonly IRuleProvider _ruleProvider; + + public YourService(IRuleProvider ruleProvider) + { + _ruleProvider = ruleProvider; + } + + public async Task ProcessAsync() + { + var input = new YourInput(); + // 执行规则验证 + await _ruleProvider.ExecuteAsync(input); + } +} +``` + +[返回目录](../../../README.md)