-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathTreeNodeContext.cs
More file actions
101 lines (90 loc) · 4.28 KB
/
Copy pathTreeNodeContext.cs
File metadata and controls
101 lines (90 loc) · 4.28 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//-----------------------------------------------------------------------
// <copyright file="TreeNodeContext.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
// <summary>
// The TreeNodeContext class.
// </summary>
//-----------------------------------------------------------------------
namespace Microsoft.Forge.TreeWalker
{
using System;
using System.Threading;
/// <summary>
/// The TreeNodeContext class holds relevant information about the tree node and session.
/// This object gets passed to CallbacksV2.BeforeVisitNode and CallbacksV2.AfterVisitNode.
/// </summary>
public class TreeNodeContext
{
/// <summary>
/// The Id of this tree walking session.
/// </summary>
public Guid SessionId { get; private set; }
/// <summary>
/// The key of the current tree node being visited by Forge.
/// </summary>
public string TreeNodeKey { get; private set; }
/// <summary>
/// The additional properties for this node.
/// </summary>
public dynamic Properties { get; private set; }
/// <summary>
/// The dynamic user-defined context object.
/// </summary>
public object UserContext { get; private set; }
/// <summary>
/// The cancellation token.
/// </summary>
public CancellationToken Token { get; private set; }
/// <summary>
/// The name of the ForgeTree in the JsonSchema.
/// </summary>
public string TreeName { get; private set; }
/// <summary>
/// The unique identifier for the root/parent tree walking session.
/// </summary>
public Guid RootSessionId { get; private set; }
/// <summary>
/// When set, the tree walker will skip all actions defined in the current tree node, and proceed to AfterVisitNode then ChildSelector.
/// Update this property inside BeforeVisitNode if you wish to use this feature for the current tree node.
/// The string context is available to check in the current TreeNode's ChildSelector via Session.GetCurrentNodeSkipActionContext().
/// </summary>
public string CurrentNodeSkipActionContext { get; set; }
/// <summary>
/// Instantiates an TreeNodeContext object.
/// </summary>
/// <param name="sessionId">The Id of this tree walking session.</param>
/// <param name="treeNodeKey">The key of the current tree node being visited by Forge.</param>
/// <param name="properties">The additional properties for this node.</param>
/// <param name="userContext">The dynamic user-defined context object.</param>
/// <param name="token">The cancellation token.</param>
/// <param name="treeName">The name of the ForgeTree in the JsonSchema.</param>
/// <param name="rootSessionId">The unique identifier for the root/parent tree walking session.</param>
/// <param name="currentNodeSkipActionContext">
/// The string context if the actions in the current tree node should be skipped, or null if actions should not be skipped.
/// </param>
public TreeNodeContext(
Guid sessionId,
string treeNodeKey,
dynamic properties,
object userContext,
CancellationToken token,
string treeName,
Guid rootSessionId,
string currentNodeSkipActionContext)
{
if (sessionId == Guid.Empty) throw new ArgumentException("sessionId cannot be empty.", "sessionId");
if (string.IsNullOrWhiteSpace(treeNodeKey)) throw new ArgumentNullException("treeNodeKey");
if (string.IsNullOrWhiteSpace(treeName)) throw new ArgumentNullException("treeName");
if (rootSessionId == Guid.Empty) throw new ArgumentException("rootSessionId cannot be empty.", "rootSessionId");
this.SessionId = sessionId;
this.TreeNodeKey = treeNodeKey;
this.Properties = properties;
this.UserContext = userContext;
this.Token = token;
this.TreeName = treeName;
this.RootSessionId = rootSessionId;
this.CurrentNodeSkipActionContext = currentNodeSkipActionContext;
}
}
}