forked from SciSharp/BotSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogicExpression.cs
More file actions
45 lines (40 loc) · 1.62 KB
/
LogicExpression.cs
File metadata and controls
45 lines (40 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System.Text.Json.Serialization;
namespace BotSharp.Core.Rules.Models;
/// <summary>
/// Represents a node in a logic expression tree used by LogicGateCondition.
///
/// Leaf node: references a parent node's result by alias and an optional custom data key.
/// e.g. { "node_alias": "check_work_order", "key": "work_order_valid" }
///
/// Operator node: combines children with "and", "or", or "not".
/// e.g. { "op": "and", "children": [ ... ] }
/// </summary>
public class LogicExpression
{
/// <summary>
/// For leaf nodes: the parent node alias whose result to inspect.
/// Using Alias avoids collisions when multiple nodes share the same Name.
/// </summary>
[JsonPropertyName("node_alias")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? NodeAlias { get; set; }
/// <summary>
/// For leaf nodes: the key in the parent node's Data dictionary that holds the boolean value.
/// If null or empty, falls back to the parent node's Success flag.
/// </summary>
[JsonPropertyName("key")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Key { get; set; }
/// <summary>
/// For operator nodes: "and", "or", or "not".
/// </summary>
[JsonPropertyName("op")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Op { get; set; }
/// <summary>
/// For operator nodes: the child expressions to combine.
/// </summary>
[JsonPropertyName("children")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<LogicExpression>? Children { get; set; }
}