-
-
Notifications
You must be signed in to change notification settings - Fork 749
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
1b0e798
commit 9736539
Showing
12 changed files
with
1,166 additions
and
77 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Planning/Nodes/ConditionPlanNode.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System.Text.Json; | ||
|
||
namespace HotChocolate.Fusion.Planning.Nodes; | ||
|
||
public sealed class ConditionPlanNode : PlanNode, ISerializablePlanNode, IPlanNodeProvider | ||
{ | ||
private readonly List<PlanNode> _nodes = []; | ||
|
||
public ConditionPlanNode( | ||
string variableName, | ||
bool passingValue, | ||
PlanNode? parent = null) | ||
{ | ||
VariableName = variableName; | ||
PassingValue = passingValue; | ||
Parent = parent; | ||
} | ||
|
||
/// <summary> | ||
/// The name of the variable that controls if this node is executed. | ||
/// </summary> | ||
public string VariableName { get; } | ||
|
||
/// <summary> | ||
/// The value the <see cref="VariableName"/> has to be, in order | ||
/// for this node to be executed. | ||
/// </summary> | ||
public bool PassingValue { get; } | ||
|
||
public IReadOnlyList<PlanNode> Nodes => _nodes; | ||
|
||
public void AddChildNode(PlanNode node) | ||
{ | ||
ArgumentNullException.ThrowIfNull(node); | ||
_nodes.Add(node); | ||
node.Parent = this; | ||
} | ||
|
||
public PlanNodeKind Kind => PlanNodeKind.Condition; | ||
|
||
public void Serialize(Utf8JsonWriter writer) | ||
{ | ||
writer.WriteStartObject(); | ||
SerializationHelper.WriteKind(writer, this); | ||
writer.WriteString("variableName", VariableName); | ||
writer.WriteBoolean("passingValue", PassingValue); | ||
SerializationHelper.WriteChildNodes(writer, this); | ||
writer.WriteEndObject(); | ||
} | ||
} | ||
|
||
public record Condition(string VariableName, bool PassingValue); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,6 @@ namespace HotChocolate.Fusion.Planning; | |
public enum PlanNodeKind | ||
{ | ||
Root, | ||
Operation | ||
Operation, | ||
Condition | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.